Mental Model
Find the longest sequence of characters that appear in the same order in both strings, but not necessarily consecutively.
Analogy: Imagine two friends telling stories. The longest common subsequence is like the longest shared storyline they both remember in the same order, even if some parts are skipped.
String1: A B C D G H
String2: A E D F H R
LCS matrix (partial):
Ø A E D F H R
Ø [0 0 0 0 0 0 0]
A [0 ↑ 0 0 0 0 0]
B [0 0 0 0 0 0 0]
C [0 0 0 0 0 0 0]
D [0 0 0 ↑ 0 0 0]
G [0 0 0 0 0 0 0]
H [0 0 0 0 0 ↑ 0]