Quiz
Big-O Time/Space Trade-offs
Analyze how converting a nested-loop pair-finder to a hash set changes both time and space complexity.
A function checks whether any two elements in an array of n integers sum to a target. A brute-force version uses two nested loops. You rewrite it to store seen values in a hash set and check for the complement in a single pass. What are the time and space complexities of the optimized version, compared to the brute-force?