Class Solution
- java.lang.Object
-
- g1001_1100.s1054_distant_barcodes.Solution
-
public class Solution extends Object
1054 - Distant Barcodes.Medium
In a warehouse, there is a row of barcodes, where the
ithbarcode isbarcodes[i].Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.
Example 1:
Input: barcodes = [1,1,1,2,2,2]
Output: [2,1,2,1,2,1]
Example 2:
Input: barcodes = [1,1,1,1,2,2,3,3]
Output: [1,3,1,3,1,2,1,2]
Constraints:
1 <= barcodes.length <= 100001 <= barcodes[i] <= 10000
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]rearrangeBarcodes(int[] barcodes)
-