-
September 7th, 2013, 09:24 AM
#1
Previous large element
Hi everyone,
Given a sequence of n numbers, {a1; a2; · · · ; an}, for each element
ai
, 1 ≤ i ≤ n, nd the index of the rightmost element inside {a1; a2; · · · ; ai1} whose value is
strictly larger than ai
. If no element is larger than ai then output 0. In other words, for
each i
pi = max{j|0 ≤ j < i; aj > ai};
in which assume a0 = ∞
O(n) should be the running time.
Please help.
Thanks
Abhinav
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|