`
frank-liu
  • 浏览: 1682309 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
问题描述: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 原问题链接:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/   问题分析   在之前的问题里讨论过根据二叉树的前序和中序遍历序列构造整棵树的过程。这里的思路和前面基本 ...
问题描述: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7   return its bottom-up level order traver ...
问题描述: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 原问题链接:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/   问题分析   这个问 ...
问题描述: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 原问题链接:https://leetcode.com/problems/maximum-depth-of-binary-tree/   问题分析   这个问题的思路比较容易得到。要求树的最大深度,对任意的一个节点来说,主要递归的求它两个子树的最大深度再加1 ...
问题描述: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7   re ...
问题描述: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7   return its level order traversal as: [ [3], [9, ...
问题描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3   But the following [1,2,2,null,3,null,3] is not: 1 / \ 2 2 ...
问题描述: Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note:A solution using O(n) space is pretty straight forward. Could you devise a constant space solution? 原问题链接:https://leetcode.com/problems/recover-bi ...
问题描述: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 原问题链接:https://leetcode.com/problems/same-tree/   问题分析   这个问题相对比较简单,判断两棵树是否相等,主要判断这两棵树对应的每个节点是否都一致。比如说,当 ...
问题描述: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both th ...
问题描述: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", return false. 原问题链接:https: ...
问题描述: 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 ...
问题描述: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ...
问题描述: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], 1 \ 2 / 3   return [1,3,2]. Note: Recursive solution is trivial, could you do it iteratively? 原问题链接:https://leetcode.com/problems/binary-tree-ino ...
问题描述: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) 原问题链接:https://leetcode.com/problems/restore-ip-add ...
Global site tag (gtag.js) - Google Analytics