Algorithms

From brute force to the optimal solution, with the reasoning in between

Algorithm write-ups organised by pattern: greedy, dynamic programming, graphs and union-find, sliding windows, linked lists and binary trees, heaps and binary search. Every post starts from the brute-force solution, walks step by step to the best time and space bounds, and ends with runnable code and a complexity analysis.

English editions are being added one by one. The full archive is in Chinese.