Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1, ... , n.
Solution:
The idea is exactly the same with Unique Binary Search Trees.
Notes: we need to use TreeNode *root = new TreeNode(i) to initialize a new struct and pointer.
The following code passes LeetCode online large judge.
Solution:
The idea is exactly the same with Unique Binary Search Trees.
Notes: we need to use TreeNode *root = new TreeNode(i) to initialize a new struct and pointer.
The following code passes LeetCode online large judge.
Comments
Post a Comment