摘要:
问题: 给定一颗BST(二叉搜索树),其中存在两个节点顺序颠倒,请找出他们,并恢复正确次序。 Example 1: Input: root = [1,3,null,null,2] Output: [3,1,null,null,2] Explanation: 3 cannot be a left ch 阅读全文
摘要:
问题: 给定一个字符串,求最少添加几个字母,能使的字符串成为回文字符串。 Example 1: Input: s = "zzazz" Output: 0 Explanation: The string "zzazz" is already palindrome we don't need any i 阅读全文
摘要:
124. Binary Tree Maximum Path Sum 问题: 求出给定二叉树中,最大路径和(节点权值相加)。(至少包含树中一个节点) Example 1: Input: [1,2,3] 1 / \ 2 3 Output: 6 Example 2: Input: [-10,9,20,nu 阅读全文
摘要:
问题: 判断一颗二叉树是否为二叉搜索树。 解法:Binary Tree(二叉树) 首先,了解 二叉搜索树BST的定义: A binary search tree is a rooted binary tree whose internal nodes each store a key greater 阅读全文