Given an array A of size N with numbers from 1 to N,for each index,how many indexes with greater number exist?


  • 0
    S

    Given an array A of size N with numbers from 1 to N in random order, return an array B such that B[i] is equal to the number of elements greater than A[i] to its right in A.

    This question is same as this Leetcode quesiton.

    Except the fact that here we know that array is permutation of [1..N]. Can we leverage that fact and optimize this? Say to time O(n)?


  • 0
    E

    I am not quite sure but I doubt if the new information can help with saving time. Looking forward to sounded answer.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.