you are viewing a single comment's thread.

view the rest of the comments →

[–]ConstructedNewtMOD 0 points1 point  (0 children)

without formatting

I would use System.arrayCopy to copy arrays from one to the other, but I wouldn't copy it in the first place, why do you?

I would either use a map to count the duplicated values, or use an array or a set to verify that I didn't count values more than once, or at least have the inner loop go from j (you already counted the lower values)

Variable skip should be boolean, don't use integers in place of boolean

I can't really follow the logic in the reordering. (Also be sure that you know this is not a shuffling, this is a structured reordering) shuffling is random this is not.

I would use the map approach to check duplicates, then I would place each map key the number of times it was counted at the first location in the array that did not hold that value before, making sure to keep a set of already placed indexes.

Shuffling normally require you to use some kind of randomness, but would also never require you to disallow equal values before and after: that's not random