This is a problem involving application of Data Structures and Algorithms. I was unable to solve it in a Geeks for Geeks Practice Test.
Problem:
There are 2 arrays of non whole numbers, A and B. A consists of people's heights. B of the numbers corresponding to each person in A, such that for every person i in A, exactly B[i] number of people with height >= A[i] should stand in-front of person i in A, after sorting A according to this condition.
We are supposed to arrange A in the given way.
Constraints:
1 <= N (number of people) <= 1000
1 <= A[i] <= 10000
Examples
- A = [3 2 1]
B = [0 1 1]
out = [3 1 2] - A = [5 3 2 6 1 4]
B = [0 1 2 0 3 2]
out = [5 3 2 1 6 4]