Count positions with sum partners
Given a list of integers and a target, count how many positions hold a value that can be matched with some other position so the two values sum exactly to target. Each position is counted at most once, and the partner must be a different position (the same value at another index is allowed). For example, in [3, 7, 3, 1] with target 10, both 3s pair with the 7 and the 7 pairs with a 3, so three positions qualify and the answer is 3; the 1 has no partner. Return the count of qualifying positions.
Implement
partnered_count(nums: list[int], target: int) → intExamples
in
[[3,7,3,1],10]out3What 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
[[3,7,3,1],10]3not run yetsample