DSAEasyArraysHashing
Two Sum
š Problem
Given an array of numbers and a target value, find two numbers in the array that add up to the target, and return their indices.
š§ Approach
A brute-force check of every pair takes O(n²). Instead, use a hash map: as you go through the array, for each number check if (target - number) already exists in the map. If yes, you found your pair instantly. If not, add the current number to the map and keep going.