2

Interview Problem — Make array increasing and then decreasing

 2 years ago
source link: http://codeforces.com/blog/entry/104884
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Interview Problem — Make array increasing and then decreasing

Rearrange array in increasing-decreasing order.

Input: 8 7 1 6 5 9

Output: 1 5 6 9 8 7

Let's consider there are no duplicates as of now.

There is no restriction on the length of increasing and decreasing sequence in the array.

We have to do it in-place O(N), without using extra memory.

Anyone could suggest the O(N) approach?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK