Solve the two sum problem, then optimise your solution from O(n) space down to O(1) space.
Asked in the Technical round stage. The candidate first produced an O(n)-space solution; the interviewer then pushed for O(1) space and he could not get there. Reported follow-up: Can you make it O(1) space complexity?
Implement def two_sum(nums, target):. Return the two values whose sum equals target, or [] if no pair exists. You may reorder nums.
def two_sum(nums, target):