public class Ass {

public static boolean[] map = new boolean[26]; public static boolean Issorted(String str, int idx, String newstring) { if(idx == str.length()) { System.out.println(newstring); return true; } char currchar = str.charAt(idx); if(map[currchar - 'a'] == true) { return Issorted(str, idx + 1, newstring); } else { newstring += currchar; map[currchar - 'a'] = true; return Issorted(str, idx + 1, newstring); } } public static void main(String[] args) { String str = "abbccdda"; Issorted(str, 0, ""); } }