← ALL NOTES
Dynamic Programming

95. Unique Binary Search Trees II

Pick each value i as the root; by the BST property, 1..i-1 must form the left subtree and i+1..n the right — two independent sub-ranges. Recursively generate all shapes of each side, then take the…

Loading…