Light intensity pairs
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.
Implement
count_light_pairs(intensities: list[int], limit: int) → intExamples
in
[[100,200,300,400],500]out2What a strong answer looks like
State 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.
0:00 of about 14 min
solution.py
InputExpectedGot
[[100,200,300,400],500]2not run yetsample