Stage 1 · Code
Arrays & Hashing
Timed Problem Set
12 curated arrays & hashing problems — Easy to Medium — to be completed in 45 minutes.
10 min readLeetCode Patterns for InterviewsCode
Instructions
Sample Array with Highlighted Elements
3start
1
4peak
1
5
9max
2
6
0
1
2
3
4
5
6
7
How to use this drill
Set a timer for 45 minutes. Work through each problem in order. If stuck for more than 8 minutes, read the hint and move on. Track which problems you needed hints for — those are your gaps.
- Attempt each problem independently before reading hints.
- Aim for optimal time/space complexity from the start.
- Write clean, readable Go — not just 'something that passes'.
- After the timer, review every solution you got wrong or needed hints for.
Problems
#1Two SumEasyHash map complement lookup · O(n) time · O(n) space#217Contains DuplicateEasySet · O(n) time · O(n) space#242Valid AnagramEasyFrequency count · O(n) time · O(1) for fixed alphabet space#49Group AnagramsMediumHash map with sorted key · O(n·k log k) time · O(n·k) space#347Top K Frequent ElementsMediumBucket sort · O(n) time · O(n) space#238Product of Array Except SelfMediumPrefix + suffix product · O(n) time · O(1) space#128Longest Consecutive SequenceMediumSet + streak start detection · O(n) time · O(n) space#560Subarray Sum Equals KMediumPrefix sum + hash map · O(n) time · O(n) space#271Encode and Decode StringsMediumLength-prefix encoding · O(n) time · O(n) space#36Valid SudokuMediumSet membership for rows/cols/boxes · O(81)=O(1) time · O(81)=O(1) space#54Spiral MatrixMediumBoundary shrinking · O(m·n) time · O(1) space#48Rotate ImageMediumTranspose + reverse · O(n²) time · O(1) space
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.