extra memory allowed... and n log n.... and resultant array should
have values f(x) in the same order as x in the first array (before
sort)

now, sort the first array and take distinct (another array)... create
a dictionary<int,int>. add each element in the sorted list and it's
index as key and value.

now, for each element in the original array, lookup it's sorted index
in the dictionary...

On Jul 26, 6:48 am, Piyush Sinha <ecstasy.piy...@gmail.com> wrote:
> You have an array like ar[]= {1,3,2,4,5,4,2}. You need to create
> another array ar_low[] such that ar_low[i] = number of elements lower
> than or equal to ar[i] in ar[i+1:n-1].
> So the output of above should be {0,2,1,2,2,1,0}
>
> Time complexity : O(nlogn)
> use of extra space allowed.
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-7483122727*
> * <https://www.facebook.com/profile.php?id=100000655377926> "NEVER SAY
> NEVER"
> *

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to