Question
A gym app pairs members for partner workouts and lists session intensities sorted ascending. A pairing is "light" if the two intensities sum to strictly less than a limit. Given the sorted list intensities and the limit, return how many unordered pairs (i < j) are light. Do it in O(n) with converging pointers — when the current pair is light, notice how many pairs that observation settles at once. Example: [100, 200, 300, 400] with limit 500 gives 2.
count_light_pairs(intensities: list[int], limit: int) → int[[100,200,300,400],500]out2State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.