Pergunta de entrevista da empresa Yelp

Print all the possible words combination from a long string with no space.

Respostas da entrevista

Sigiloso

5 de mai. de 2015

public class Main { private static void combination(String prefix, String str){ int n = str.length(); System.out.println(prefix); for (int i = 0; i < n; i++) { combination(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1)); } } public static void main(String[] args) { combination("", "abc"); } }

2

Sigiloso

27 de abr. de 2015

Do you mean all permutations of the string or print all the possible words from a given dictionary? Can you please elaborate this question further?