Programming Questions

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?

SrdjaNo1
posted this question on 8/4/17 **|**

1

Yes, actually this question have no logic. Let supposefor 5 the output is 1,1,3,3,4 and for 1 the list should be empty because there is no number in list that is less than 1.
So, this question have big bug.

salman1538

answered on 10/22/17

0

I ran into the same problem. The tests are for "nearest smaller OR EQUAL values," but the instructions say to use "nearest smaller values."

bhanson

answered on 05/29/18

Log in to write an answer.