LeetCode知识点总结 – 897
LeetCode 897. Increasing Order Search Tree
考点难度TreeEasy
题目
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.
思路
先用inorder traversal把tree里的数字从小到大排列,再把新建的nodes连起来。
答案
class Solution {
public TreeNode increasingBST(TreeNode root) {
List
共有 0 条评论