len(ratings) members, and ratings[i] is the rating of member i. They are split into mentor and apprentice pairs, but a pair is allowed only if the mentor's rating is at least twice the apprentice's (2 · apprentice ≤ mentor). Each person joins at most one pair.
Return the largest number of people who can end up in pairs.ratings=[4, 1, 9, 3] → 4
Pairs (1, 4) and (3, 9): each mentor is rated at least twice as high. All four people are paired.
ratings=[5, 6, 9] → 0
Even the lowest rated person (5) has nobody rated 10 or more.
ratings=[2, 2, 5, 3] → 2
Only the 5 can mentor anyone, and only one apprentice: a single pair, two people.
ratings=[4, 1, 9, 3]
4
Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.