LC 96
Unique Binary Search Trees
Medium · LC 1–100
Candidate solution routes
Primary
FreeTree dynamic programming
Invariant: dfs(u,parent) returns the exact optimum for every boundary mode of u's subtree. Distinct child subtrees interact only through u and can therefore be folded independently.
candidate confidence: 0.675 · metadata_only
Alternate 1
FreeBST ordering / inorder traversal
Invariant: At node entry, (low,high) is the intersection of all ancestor constraints; a legal value lies inside it. In inorder form, every visited value is greater than the previous one.
candidate confidence: 0.740 · metadata_only
How to use this page
Read the statement and constraints first, then validate recognition signals, invariant, and complexity. Candidate score is not correctness evidence.