You’re given an array barcodes where each element represents a barcode number.
You need to rearrange them so that no two adjacent elements are equal.
It’s guaranteed that at least one valid arrangement exists.
Input: barcodes = [1,1,1,2,2,2]
Output: [1, 2, 1, 2, 1, 2]
Input: barcodes = [1,1,1,1,2,2,3,3]
Output: [1, 2, 1, 3, 1, 2, 1, 3]
Accepted:
Submission: