public static void main(String args[]){
        int input[] = {2,1,5,1,3,5,3,3,4};
        int input1[] = {1,2,3,8,8,8,7,8};
        GroupElementsInSizeM gps = new GroupElementsInSizeM();
        boolean r = gps.group(input1, 3);
        System.out.println(r);
        for(int i=0; i < input1.length; i++){
            System.out.println(input1[i]);
        }
    }
http://www.careercup.com/question?id=6026101998485504
This answer two questions.
Group elements in size m such that in every group only unique elements are possible.
It also answers question where rearrange array such that same elements are exactly m
distance from each other
src/com/interview/array/GroupElementsInSizeM.java