Loud and Rich
Try to solve the Loud and Rich problem.
We'll cover the following
Statement
You’re given a group of people where everyone has a specific amount of money and a different level of quietness. Additionally, you’re given an array richer
= [, ], so that has more money than . The quietness level of each person is represented using an array named quiet
.
Return an integer array res
, where res[i]
= y
if y
has the lowest value in quiet[y]
among all people who have equal or more money than the person i
.
Constraints:
-
quiet.length
-
quiet[i]
- All the values of
quiet
are unique. -
richer.length
-
x[i]
,y[i]
n
- All the pairs of
richer
are unique. - The observations in
richer
are all logically consistent.
Example
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.