Let say I have an array like this.
int[] arr = {1,2,3,4,4,5,6,7,8,8,8,1};
How do I shuffle it, but have all equal values beside each other?
Sample expected output after shuffle:
3,1,1,8,8,8,7,2,4,4,6,5
Let say I have an array like this.
int[] arr = {1,2,3,4,4,5,6,7,8,8,8,1};
How do I shuffle it, but have all equal values beside each other?
Sample expected output after shuffle:
3,1,1,8,8,8,7,2,4,4,6,5
On
You can do something like this:
counts.v in the shuffled array, write v into the output array counts[v] times.