java.lang.Object
g0001_0100.s0095_unique_binary_search_trees_ii.Solution

public class Solution extends Object
95 - Unique Binary Search Trees II.<p>Medium</p> <p>Given an integer <code>n</code>, return <em>all the structurally unique **BST&rsquo;**s (binary search trees), which has exactly</em> <code>n</code> <em>nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/01/18/uniquebstn3.jpg" alt="" /></p> <p><strong>Input:</strong> n = 3</p> <p><strong>Output:</strong> [[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],[3,2,null,1]]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 1</p> <p><strong>Output:</strong> <a href="1">1</a></p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 8</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • generateTrees

      public List<TreeNode> generateTrees(int n)