Longest common subsequence

The longest common subsequence of two strings fills a grid where each cell comes from the cell above, to the left or diagonally before it, in $O(mn)$, and walking back through the grid recovers the subsequence itself, which is how a diff finds what changed.

From Data Structures and Algorithms.