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. |