Skip to main content

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

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.

Back to the full Data Structures and Algorithms roadmap