Two Sum using HashMap

00:00
EasyArrayHashMap
AmazonTCS

Find two indices where values sum to target using a HashMap for O(n) time. Explain why this beats O(n²) brute force.

Examples

Input → [2,7,11,15], t=9
Output → [0,1]
Input → [3,2,4], t=6
Output → [1,2]
Input → [0,4,3,0], t=0
Output → [0,3]