Tail Recursion in Java
Idea : Always consider the first character alphabetically which will give yes to the trailing output based on the content stored in the set, and append that cha
**Idea** : Always consider the first character alphabetically which will give yes to the trailing output based on the content stored in the set, and append that character to the new String and remove that character from the present set. \nCode :\n```\nclass Solution {\n    public boolean contains(Set<Character>set,String ch){\n       Set<Character>nset = new HashSet<>();\n       for(char c : ch.toCharArray()){\n           if(set.contains(c)) nset.add(c);\n       }\n        return nset.size() == set.size();\n    }\n    public String solve(String ch,Set<Character>set){\n        if(set.size()==0){\n            return "";\n        }\n        for(char c= \'a\';c<=\'z\';c++){\n            if(set.contains(c)){\n                int index = ch.indexOf(c);\n                String ch_ = ch.substring(index);\n                if(contains(set,ch_)){\n                    set.remove(c);\n                    return c + solve(ch_,set);\n                }\n            }\n        }\n        return "";\n    }\n    public String smallestSubsequence(String s) {\n       Set<Character>set = new HashSet<>();\n       for(char ch : s.toCharArray()){\n           set.add(ch);\n       }\n       return solve(s,set);\n    }\n}\n```
['Greedy', 'Recursion', 'Java']