public boolean rearrangeAtleastkDistanceAway(Map<Character,Integer> charCount,char output[],int pos,int k){
        if(pos == output.length && charCount.size() == 0){
            return true;
        }
        Set<Character> allChars = new HashSet<Character>();
        for(char ch : charCount.keySet()){
            allChars.add(ch);
        }
        getAllFeasibleCharacters(output,k,pos,allChars);
        for(char ch : allChars){
            output[pos] = ch;
            int c = charCount.get(ch);
            if(c -1 == 0){
                charCount.remove(ch);
            }else{
                charCount.put(ch, c-1);
            }
            boolean r = rearrangeAtleastkDistanceAway(charCount, output, pos+1, k);
            if(r){
                return true;
            }
            charCount.put(ch, c);
        }
        return false;
    }
http://www.geeksforgeeks.org/rearrange-a-string-so-that-all-same-characters-become-at-least-d-distance-away/
src/com/interview/string/RearrangeDuplicateCharsdDistanceAway.java