Generating all unique permutations of a string
Pay attention to your substrings. Given s = "abc", then the following return empty strings.

String pre = s.substring(0,0);
String post = s.substring(3);


Consider (temporarily) adding logging statements inside your innermost loop and examining the results of calling permute("abc") to see how many times you add the same strings to the set. Try to avoid adding to the set a value already in the set concatenated to an empty string, since this gives you no new values in the set.