Two paradigms: quadratic DP for clarity and O(n log n) patience sorting for performance. Shows evolution of optimization.
or O(n²)
piles/parents
Patience sorting piles evolution and placement positions per element.
Compare O(n²) dp with O(n log n) method, reconstruction notes and variants.