Categorygithub.com/szhou12/leetcode-goleetcode0095-Unique-Binary-Search-Trees-II
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

95. Unique Binary Search Trees II

Solution idea

Recursion

  1. 穷举 root 节点的所有可能

  2. 递归构造出左、右子树的所有合法 BST

  3. root 节点穷举所有左、右子树的组合

Time complexity = $O(\frac{4^n}{n^{1/2}})$

Resource

Unique Binary Search Trees II