tree
gandyLyn
Keep walking
展开
-
leetcode 103.Binary Tree Zigzag Level Order Traversal(C语言实现)
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 tre...原创 2019-09-28 08:33:26 · 55 阅读 · 0 评论 -
leetcode 111. Minimum Depth of Binary Tree
这题不能只将104求最大深度的代码改成小于号,即int minDepth(TreeNode* root){ if(!root) return 0; int left=minDepth(root->left); int right=minDepth(root->right); return 1+(left<right?left...原创 2019-09-28 09:03:52 · 42 阅读 · 0 评论 -
leetcode 108. Convert Sorted Array to Binary Search Tree
取数组[left,right]中间点mid=(left+right)/2作为根结点,并将原数组划分为[left,mid-1],[mid+1,right]两个子数组。将两子数组递归结果赋值给根的左右指针域。*注意,双分支递归不宜直接改用循环。原创 2019-09-28 09:13:17 · 47 阅读 · 0 评论 -
leetcode 968. Univalued Binary Tree
A binary tree is univalued if every node in the tree has the same value.Return trueif and only if the given tree is univalued.来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/univalued-binary-...原创 2019-09-30 09:13:03 · 63 阅读 · 0 评论