LeetCode ยท Arrays & Hashing
Arrays & Hashing Problem Set
Foundation problems covering array manipulation, frequency counting, and hash-map lookups. Master these first โ they appear in almost every interview.
| Difficulty | Pattern | Problem | Key Insight |
|---|---|---|---|
| Easy | hashing | LC 1 ยท Two Sum | Hash map for complement lookup. O(n) time, O(n) space. |
| Easy | hashing | LC 217 ยท Contains Duplicate | HashSet membership check. O(n). |
| Easy | hashing | LC 242 ยท Valid Anagram | Frequency count with array or hash map. O(n). |
| Medium | hashing | LC 49 ยท Group Anagrams | Sorted-string key โ group values. O(n ยท k log k). |
| Medium | array | LC 238 ยท Product of Array Except Self | Prefix and suffix products without division. O(n). |
| Medium | hashing | LC 347 ยท Top K Frequent Elements | Frequency map + bucket sort or min-heap. O(n). |
| Medium | hashing | LC 128 ยท Longest Consecutive Sequence | HashSet for O(1) lookups. Only start from sequence heads. O(n). |
| Medium | array | LC 36 ยท Valid Sudoku | HashSet per row, column, and 3ร3 box. O(81) = O(1). |
| Medium | design | LC 271 ยท Encode and Decode Strings | Length-prefix encoding. O(n) encode and decode. |
| Medium | sliding-window | LC 3 ยท Longest Substring Without Repeating Characters | Sliding window + HashSet/HashMap. O(n). |
| Medium | array | LC 189 ยท Rotate Array | Three reversals: whole array, first k, remaining n-k. O(n) time, O(1) space. |