Algorithms

All levels

Sorting, dynamic programming, BFS/DFS, two pointers — with complexity analysis.

Overview

Key concepts

Must-know algorithms

Binary search · Merge sort / quick sort · Dynamic programming · Backtracking · Union-Find · Dijkstra's / Bellman-Ford · Topological sort

Complexity

Always state time and space complexity. Aim for O(n log n) or better. Know the trade-offs between time and space.

Question Bank

Practice questions

Common questions asked at Amazon for this topic. Check them off as you practice. Progress is saved in your browser.

0/8 practiced

Implement binary search and all its variants (first occurrence, last occurrence, rotated array).

Easy

Coin Change: find the minimum number of coins to make amount N.

Medium

Longest Increasing Subsequence (LIS) — find its length and reconstruct it.

Medium

Word Break: can a string be segmented into words from a given dictionary?

Medium

Generate all permutations of a string or array (backtracking).

Medium

Trapping Rain Water: given an elevation map, how much water can be trapped?

Hard

Detect a cycle in a directed graph.

Medium

Dijkstra's shortest path algorithm — implement it and state its time complexity.

Hard

Resources

Go deeper

Free, curated materials to supplement your prep.

Previous
Data Structures
Next
Object-Oriented Design