Q: Write a program to print all the possible combinations of a given string.
Anonymous
public static void stringComb(String s) { stringComb("", s); } private static void stringComb(String prefix, String s) { int N = s.length(); if (N == 0) System.out.println(prefix); else { for (int i = 0; i < N; i++) stringComb(prefix + s.charAt(i), s.substring(0, i) + s.substring(i+1, N)); } }
Check out your Company Bowl for anonymous work chats.