Ctrl K

Climbing Gym Points

Medium
A climbing gym is hosting a competition. The array climbers gives each participant's skill level, the array routes gives the difficulty of each route, and points[j] is how many points route j is worth. A participant with skill s can complete route j when routes[j] ≤ s. Each participant tries every route independently of the others and never gets tired, but can count each route only once. Return an array of the same length as climbers whose i-th element is the largest total score the i-th participant can earn.
Example 1
climbers=[3, 1, 6], routes=[2, 5, 1, 3], points=[4, 10, 1, 7] → [12, 1, 22]

The climber with skill 3 completes the routes of difficulty 2, 1 and 3: 4 + 1 + 7 = 12. Skill 1 completes only the difficulty-1 route: 1 point. Skill 6 completes every route: 22.

Example 2
climbers=[2, 2], routes=[4, 9], points=[5, 5] → [0, 0]

Both routes are harder than either climber's skill, so both score 0.

Example 3
climbers=[5], routes=[5, 5, 6], points=[2, 3, 100] → [5]

Routes of difficulty exactly 5 are within reach, the one of difficulty 6 is not: 2 + 3 = 5.

Constraints
  • 1 ≤ climbers.length ≤ 10⁵
  • 1 ≤ routes.length = points.length ≤ 10⁵
  • 1 ≤ climbers[i], routes[j], points[j] ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsFlowerbed Beauty on a Budget HardStudios for Recording Sessions MediumTriples Under a Limit MediumWarm Every Cabin MediumPairs With a Fixed Gap Medium
loading Python…
Input
climbers=[3, 1, 6], routes=[2, 5, 1, 3], points=[4, 10, 1, 7]
Expected
[12, 1, 22]

Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.