Panda Guru LogoPanda
Guru

Amazon | Onsite | SDE I

Round 1

Questions: I have an array of numbers (not necessarily sorted). How do I return an array of the first index of each number if it was a sorted array?

nums = [8,5,4,3,1]

answer = [4,3,2,1,0]

For each number, you replace it with the first index it would have in a sorted array.

nums = [9, 9, 5, 4, 2, 1]

answer = [4, 4, 3, 2, 1, 0]

Is it possible to do this faster than O(nlogn)? Space does not matter.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.