Nearest Smaller Values Question
Input: 5, 3, 1, 9, 7, 3, 4, 1
Output: "-1 -1 -1 1 1 1 3 1"
Take the array of integers stored in arr, and for each element in the list, search all the previous values for the nearest element that is smaller than the current element and create a new list from these numbers.
So, as the last value of input is 1, and there is no zero in the array, the last number should be -1 not 1? I see that same numbers are also included but that is not what was asked in this challenge as far as I understood? Is this a bug?
posted this question on 8/4/17 |