Trains the technique from
LeetCode 851Loud and RichThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A workshop has n members labelled 0 to n - 1. Every member has a different steadiness score; patience[i] is the score of member i, and a smaller score means a steadier hand.
You are also given pairs. Each pairs[i] = [a, b] is a note from the foreman saying member a has strictly more workshop experience than member b. Experience carries through the notes: if a has more than b and b has more than c, then a has more than c. The notes never contradict each other.
For every member x, consider the members who have at least as much experience as x, which always includes x. Exactly one of them has the smallest steadiness score. Return the list answer where answer[x] is that member's label.
Example 1
Member 0 has more experience than member 1, who has more than member 2, so member 0 also has more than member 2. Member 0's score of 0 is the smallest in the workshop, and member 0 counts for all three members, so every entry is 0.
Example 2
Members 0 and 1 have no notes above them, so each keeps their own label. Member 2's score of 0 beats members 0 and 1, so entry 2 is member 2. Member 3 is under members 2, 0 and 1, and member 2's score of 0 is the smallest of the four, so entry 3 is member 2 as well.
Example 3
With no notes at all, nobody is known to have more experience than anyone else, so each member is the only candidate for their own entry.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def steadiest_peer(pairs: list[list[int]], patience: list[int]) -> list[int]:public int[] steadiestPeer(int[][] pairs, int[] patience)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.