Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    1054 - Distant Barcodes.

    Medium

    In a warehouse, there is a row of barcodes, where the <code>i<sup>th</sup></code> barcode is barcodes[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 &lt;= barcodes.length &lt;= 10000

    • 1 &lt;= barcodes[i] &lt;= 10000

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final IntArray rearrangeBarcodes(IntArray barcodes)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait