Thoughts about Wiggle Sort

  • 1

    I had to admit that I spent a lot of time thinking about 'Color Sort' and 'findKthLargest' problems. Here are tips about the relations.

    1. Three different colors are similar to elements smaller than pivot, elements equal to pivot, and elements larger than pivot;
    2. The mapping indices is just the order to traverse the numbers;
    3. There cannot be an element appears more than (len+1)/2 times, so we must find the median at fist;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.