hello guys i was given homework problem where it asks me to find all distinct substring of a string. I have implemented a method which will tell you all the substrings of s
Insert any new sub string into an array and check if it is already available available there don't add it to the array else do. When done loop through the array and print out the distinct sub strings.
To check if an element exists in an array create a function that takes an array and a value as parameters. It would loop through the array looking for the value if found return true. Out of the loop return false.
e.g.
public static boolean(String target, String[] arr)
{
for(int i = 0; i < arr.length; i++){
if(arr[i].equals(target))
return true;
}
return false;
}