Two Sum (LC #1) is the foundation of array problems. Given an array and target, find two indices that sum to the target. The brute force checks all pairs in . The optimal approach uses a hash map: for each element, check if target minus current exists in the map. If yes, return both indices. If no, add current to the map. This runs in time and space. Meta asks variants: what if the array is sorted (use two pointers)? What if you need all pairs? What about Sum or Sum?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/arrays-strings/two-sum
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████