Skip to content

Latest commit

 

History

History
22 lines (14 loc) · 540 Bytes

weird-sort.md

File metadata and controls

22 lines (14 loc) · 540 Bytes

Weird Sort Problem

Having a sequence of N integers a1, a2, ..., aN, you need to order them in a way when no two consecutive integers have consecutive values. In other words, for all i, where 0<i<N, condition a1+1 ≠ a1+1 should be satisfied for the final sequence.

Sample

Sample Input

  • 1 2
  • 1 2 3 4 5 6
  • 1 1 2 2 3 3

Sample Output

  • 2 1
  • 1 3 2 4 6 5
  • 1 1 3 3 2 2

WeirdSortTest.java