Your question is Hash Map for Pair Sums and Duplicates. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An Atos monitoring pipeline receives an unsorted array of integer event codes. Implement a function that identifies both distinct value pairs whose sum equals a target and values that occur at least twice, using hash-based lookups.
Return a dictionary with two keys: pairs, containing each distinct pair as a two-element list in the order it is first discovered, with the smaller value first; and duplicates, containing each duplicated value once in the order it reaches its second occurrence.
nums, a list of integers, and target, an integer.{"pairs": list[list[int]], "duplicates": list[int]}.def find_pairs_and_duplicates(nums, target):