Imagine a social circle where wealth creates a hierarchy, but quietness is the most valued trait. You're given information about n people, each with different amounts of money and varying levels of quietness.
You have an array richer where richer[i] = [a, b] means person a has more money than person b. You also have an array quiet where quiet[i] represents how quiet person i is (lower values mean quieter).
Your task: For each person, find the quietest person among all people who have equal or more money than them. This could be themselves if they're the quietest in their wealth tier!
Example: If person 0 has $100, person 1 has $200, and person 2 has $150, and their quietness levels are [5, 2, 8], then for person 0, we need to find the quietest among {person 1, person 2} since both are richer. Person 1 with quietness 2 would be the answer.
Input & Output
Constraints
- n == quiet.length
- 1 โค n โค 500
- 0 โค quiet[i] < n
- All values of quiet are unique
- 0 โค richer.length โค n * (n - 1) / 2
- 0 โค ai, bi < n
- ai != bi
- All pairs (ai, bi) are unique
- The observations in richer are all logically consistent