95. Unique Binary Search Trees II
Posted 蓝色地中海
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了95. Unique Binary Search Trees II相关的知识,希望对你有一定的参考价值。
Problem statement:
Given an integer n, generate all structurally unique BST\'s (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST\'s shown below.
1 3 3 2 1 \\ / / / \\ \\ 3 2 1 1 3 2 / / \\ \\ 2 1 2 3
Solutions:
Contrast with 96. Unique Binary Search Trees, this problem wants all possible solutions. Obviously, it is DFS.
以上是关于95. Unique Binary Search Trees II的主要内容,如果未能解决你的问题,请参考以下文章
Leetcode 95. Unique Binary Search Trees II
Leetcode 95. Unique Binary Search Trees II
LeetCode 95. Unique Binary Search Trees II
95. Unique Binary Search Trees II