i***0 发帖数: 8469 | 1 Solve this task using recursion. how to ?
“Given a string build all possible non-zero length substrings from it.
Example
Input:
abc
Output:
a
b
c
ab
ac
bc
abc
Solve this task using recursion.” | j*******2 发帖数: 18 | 2 This is my version in Java:
public static void printsubString(char[] terms, int i, String last){
if(i == terms.length)
return;
for(int j = i; j < terms.length; j++){
System.out.println(last + String.valueOf(terms[j]));
printsubString(terms,j + 1, last + String.valueOf(terms[j]));
}
} |
|