Given an array of integers, for each element of the array, print the
first number on the right side of the element which is smaller than
it. print -1 is there is no such element.
eg: 3,4,2,18,19,1,10
Ans: 2,2,1,10,10,-1,-1
O(n^2) solution is trivial.
One solution could be:
Insert the elements
26, 2011 at 5:22 PM, Shikhar shikharko...@gmail.com wrote:
Given an array of integers, for each element of the array, print the
first number on the right side of the element which is smaller than
it. print -1 is there is no such element.
eg: 3,4,2,18,19,1,10
Ans: 2,2,1,10,10,-1,-1
O(n
@ankit: you are right...sorry about the error
On Jul 26, 5:11 pm, ankit sambyal ankitsamb...@gmail.com wrote:
The O/P of ur example should be 2,2,1,1,1,-1,-1
or am I getting it wrong ??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To