public static void main(String args[]){
        String str = "ABBACCCCDD"; 
        char input[] = str.toCharArray();
        RearrangeDuplicateCharsdDistanceAway rdc  =new RearrangeDuplicateCharsdDistanceAway();
        boolean r =rdc.rearrangeAtleastkDistanceAway(input, 3);
        if(r){
            for(char ch : input){
                System.out.print(ch + " ");
            }
        }else{
            System.out.println("Not possible");
        }
    }
http://www.geeksforgeeks.org/rearrange-a-string-so-that-all-same-characters-become-at-least-d-distance-away/
src/com/interview/string/RearrangeDuplicateCharsdDistanceAway.java