For each number, find the next smaller number in the array. If next smaller number does not exists, put 0.
Eg.
Input: 1 5 7 6 3 1 6 2 9 2 7
Output: 0 3 6 3 1 0 2 0 2 0 0
Eg.
Input: 1 5 7 6 3 1 6 2 9 2 7
Output: 0 3 6 3 1 0 2 0 2 0 0
Design and implementation of interesting data structures and algorithms. You may find it useful either in your computer science course curriculum or in technical interviews of companies like Microsoft, Amazon, Google, Yahoo, Sun, Oracle etc
No comments:
Post a Comment