You are given an array of integers and a target value. Return indices of two numbers that add to the target.
The naive solution checks all pairs. The optimized solution uses a hash map. Before solving, estimate the complexity of both approaches.
(Comparing O(n²) vs O(n))
You are given an array of integers and a target value. Return indices of two numbers that add to the target.
The naive solution checks all pairs. The optimized solution uses a hash map. Before solving, estimate the complexity of both approaches.