- Warmup (Easy)
- 1. Two Sum
- 2. Contains Duplicate
- 3. Valid Anagram
- Medium (Core)
- 4. Group Anagrams
- 5. Top K Frequent Elements (you attempted this)
- 6. Product of Array Except Self
- 7. Longest Consecutive Sequence
- 8. Encode and Decode Strings (Go-to for system design flavored)
- Extra (if you have time)
- 9. Valid Sudoku
- 10. Longest Consecutive Sequence (Redo in Go)
- Practice Session 1 — Start Here
Arrays Practice
Week 1 — Arrays & Hashing
Target: 10 problems over a few sessions Language: Python (fast for DSA) or Go (if you want role-specific)
Warmup (Easy)
1. Two Sum
Link: LeetCode 1
Given nums = [2,7,11,15], target = 9, return [0, 1].
Key technique: Hashmap — store {value: index}, check if target - current exists. O(n) time, O(n) space.
2. Contains Duplicate
Link: LeetCode 217
Return true if any value appears twice.
Key technique: Set — O(n).
3. Valid Anagram
Link: LeetCode 242
s = "anagram", t = "nagaram" → true.
Key technique: Frequency count via Counter / hashmap of 26 chars (O(n)).
Medium (Core)
4. Group Anagrams
Link: LeetCode 49
["eat","tea","tan","ate","nat","bat"] → [["bat"],["nat","tan"],["ate","eat","tea"]]
Key technique: Sorted string as key, or custom char-count tuple. O(n · k log k).
5. Top K Frequent Elements (you attempted this)
Link: LeetCode 347
Two solution paths: - Min-heap (size k): O(n log k) — pop smallest when size > k - Bucket sort (frequency array): O(n) — optimal. Index = frequency, value = list of nums
6. Product of Array Except Self
Link: LeetCode 238
[1,2,3,4] → [24,12,8,6]. No division allowed.
Key technique: Prefix product → suffix product. Two passes, O(n) time, O(1) extra space.
7. Longest Consecutive Sequence
Link: LeetCode 128
[100,4,200,1,3,2] → 4 (sequence [1,2,3,4]). O(n) time required.
Key technique: Set → only start sequences where num-1 is NOT in set. Count forward.
8. Encode and Decode Strings (Go-to for system design flavored)
Link: LeetCode 271
Design an encoder that turns ["neet","code","love","you"] into a single string and back.
Key technique: Length-prefix encoding: "4#neet4#code4#love3#you"
Extra (if you have time)
9. Valid Sudoku
Link: LeetCode 36
Check if a 9×9 board is valid. Use sets for rows, columns, and 3×3 boxes.
10. Longest Consecutive Sequence (Redo in Go)
Practice Session 1 — Start Here
Solve #1 (Two Sum) and #3 (Valid Anagram) first — they're warmups. Then tackle #5 (Top K Frequent) — the one from the diagnostic — with bucket sort to learn the optimal solution.