Core Patterns for Data Structures and Algorithmss
Core patterns are the first reusable problem-solving techniques in DSA: using arrays with hash maps for fast lookup and counting, and the two pointers technique for scanning sorted or paired data. They teach how a hash table trades memory for speed and appear in a large share of beginner interview problems.
Stage: Foundations · Part of the Data Structures and Algorithms roadmap · Last reviewed 19 November 2026
What to learn in Core Patterns
- Use a hash map to find two numbers that sum to a target in one pass
- Count frequencies with a dictionary and detect duplicates in linear time
- Apply two pointers to reverse a string or check a palindrome in place
- Solve a three-sum style problem by sorting and moving two pointers
- State time and space complexity for each solution in Big-O
Core Patterns interview questions
Why is a hash map lookup considered O(1)?
A hash function maps a key to a bucket index, so a lookup usually jumps straight to the right slot regardless of size. This is average-case; many collisions can degrade it toward O(n), which good hash functions and resizing avoid.
When does the two pointers technique apply?
It applies when the data is sorted or you can move from both ends, so each step lets you discard options, such as pair-sum on a sorted array. It reduces a nested-loop O(n squared) search to a single O(n) pass.
Where Core Patterns fits in the Data Structures and Algorithms roadmap
Core Patterns belongs to the Foundations stage (beginner level), which takes about 43 hours. Arrays and pointers.
Other units in this stage
Back to the full Data Structures and Algorithms roadmap