Code RoomCount positions with sum partners
MediumPrep Room Coding #430

Count positions with sum partners

CodingAlgorithms & data structuresEntry–Mid~14 min

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) → int
Examples
in[[3,7,3,1],10]out3
What 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
InputExpectedGot
[[3,7,3,1],10]3not run yetsample