Photon's frontend event inspector needs to determine whether two event scores in an unsorted array combine to a specified target value. Given an integer array and a target sum, return True if two distinct elements add up to the target, otherwise return False.
The same value may appear multiple times, and each array position can be used at most once. Aim for a single-pass solution that does not modify the input array. After presenting the baseline solution, explain how you would adapt it if the array were already sorted, if memory were limited, or if the input arrived as a stream.
Implement has_pair_sum(nums, target).
nums, a list of integers, and target, an integer.i and j exist such that i != j and nums[i] + nums[j] == target.def has_pair_sum(nums, target):