Ad
  • Custom User Avatar

    Thanks for the reply. I realized that I misunderstood your solution.

         input: [0, 1, 2, 3, 4, 5, 6]
         left:  [4, 3, 2, 1, 6, 5, 0]  // mine
         right: [6, 3, 2, 1, 0, 5, 4]  // solution
    

    I got the result after transition but not the position array.

    I made it!

  • Custom User Avatar
    | | | | | |_|
    | |_| | |_| |
    |_| |_| | |_|
    | |_| |_| | |
    | | |_| |_| |
    | |_| | | | |
    |_| | | |_| |
    | |_| |_| | |
    

    How can 0 become 6, I thought it should be 4.
    [down down right right right down down right]
    And 6 becomes 4?
    [left left down left left left left down]

  • Custom User Avatar

    Learn some math guys, no space occupied, operate in O(n) time.