Given an array find the nearest smaller element b[i] for every element a] in the array
Answers
Answered by
0
Answer:
Input: arr[] = {1, 6, 4, 10, 2, 5}
Output: {_, 1, 1, 4, 1, 2}
First element ('1') has no element on left side. For 6,
there is only one smaller element on left side '1'.
For 10, there are three smaller elements on left side (1,
6 and 4), nearest among the three elements is 4.
Input: arr[] = {1, 3, 0, 2, 5}
Output: {_, 1, _, 0, 2}
it might be correct or maybe not
correct me if wrong
and If right mark it as best..!!!
Similar questions