Leetcode 0095. Unique Binary Search Trees II
95. Unique Binary Search Trees IIGiven an integer n, return *all the structurally unique **BST'*s (binary search trees), which has exactly n nodes of unique values from 1 to n. Return the answer in any order. Example 1: 12Input: n = 3Output: [[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],[3,2,null,1]] Example 2: 12Input: n = 1Output: [[1]] 题目大意给定一个整数 n,生成所有由 1 到 n 为节点所组成的结构独特的二叉搜索树(BST)。返回这些二叉搜索树的根节点列表。 二叉搜索树的特性是:对于任意节点,其左子树中的所有节点值都小于该节点值,右子树中的所有节点值都大于该节点值。 例如: 输入 n = 3,存在...
Leetcode 0094. Binary Tree Inorder Traversal
94. Binary Tree Inorder TraversalGiven the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Explanation: Example 2: Input: root = [1,2,3,4,5,null,8,null,null,6,7,9] Output: [4,2,6,5,7,1,3,9,8] Explanation: Example 3: Input: root = [] Output: [] Example 4: Input: root = [1] Output: [1] 题目大意 给定一棵二叉树的根节点 root,返回其节点值的中序遍历结果。中序遍历的顺序是「左子树 → 根节点 → 右子树」,遵循 “左 - 根 - 右” 的递归逻辑,且需按此顺序收集所有节点值。 解题思路二叉...

