摘要:
题目描述 求给定二叉树的最大深度, 最大深度是指树的根结点到最远叶子结点的最长路径上结点的数量。 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longe
阅读全文
摘要:
题目描述 给出一个仅包含字符'(',')','{','}','['和']',的字符串,判断给出的字符串是否是合法的括号序列 括号必须以正确的顺序关闭,"()"和"()[]{}"都是合法的括号序列,但"(]"和"([)]"不合法。 Given a string containing just the
阅读全文
摘要:
题目描述 求给定的二叉树的前序遍历。 例如: 给定的二叉树为{1,#,2,3}, 1 \ 2 / 3 返回:[1,2,3]. 备注;用递归来解这道题太没有新意了,可以给出迭代的解法么? /** * struct TreeNode { * int val; * struct TreeNode *lef
阅读全文
摘要:
题目描述 求给定的二叉树的后序遍历。 例如: 给定的二叉树为{1,#,2,3}, 1↵ ↵ 2↵ /↵ 3↵ 返回[3,2,1]. 备注;用递归来解这道题太没有新意了,可以给出迭代的解法么? Given a binary tree, return the postorder traversal of
阅读全文
摘要:
题目描述 求给定二叉树的最小深度。最小深度是指树的根结点到最近叶子结点的最短路径上结点的数量。 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortes
阅读全文