Leetcode 98 Validate Binary Search 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 n...
阅读全文
posted @
2015-07-03 13:23
又岸
阅读(316)
推荐(0)
Leetcode 103 Binary Tree Zigzag Level Order Traversal
摘要:和之前的层次遍历是一样的,只不过要在最后处理数组的时候,下一个层次利用reverse反转就好 1 class Solution { 2 public: 3 vector > zigzagLevelOrder(TreeNode* root) { 4 vector > v; 5 ...
阅读全文
posted @
2015-07-03 09:27
又岸
阅读(201)
推荐(0)
Leetcode 102/107 Binary Tree Level Order Traversal
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
阅读全文
posted @
2015-07-03 06:21
又岸
阅读(167)
推荐(0)
leetcode 101 Symmetric Tree
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
阅读全文
posted @
2015-06-19 09:11
又岸
阅读(146)
推荐(0)
Leetcode 94 Binary Tree Inorder Traversal
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
阅读全文
posted @
2015-06-17 12:40
又岸
阅读(136)
推荐(0)
leetcode 100 Same Tree
摘要: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 an...
阅读全文
posted @
2015-06-12 09:20
又岸
阅读(199)
推荐(0)
leetcode 110 Balanced Binary Tree
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
阅读全文
posted @
2015-06-11 10:05
又岸
阅读(146)
推荐(0)
Leetcode 111/104 Minimum/Maximum depth of binary tree
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le...
阅读全文
posted @
2015-06-08 04:41
又岸
阅读(157)
推荐(0)
Leetcode 117 Populating Next Right Pointers in Each Node 2
摘要:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
阅读全文
posted @
2015-06-07 00:53
又岸
阅读(175)
推荐(0)
Leetcode 116 Populating Next Right Pointers in Each Node
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
阅读全文
posted @
2015-06-04 10:52
又岸
阅读(150)
推荐(0)
Leetcode 129 Sum Root to Leaf Numbers
摘要:/** * ID: 129 * Name: Sum Root to Leaf Numbers * Data Structure: * Time Complexity: * Space Complexity: * Tag: Tree * Difficult: Medium * Algorithm...
阅读全文
posted @
2015-06-04 08:15
又岸
阅读(102)
推荐(0)
Leetcode 109 Convert Sorted List to Binary Search Tree
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.主要想好返回值,每层的返回的东西思路一: 就是要每次遍历两遍来找中间值。思路二: ...
阅读全文
posted @
2015-04-24 13:04
又岸
阅读(109)
推荐(0)
Leetcode 112 Path Sum
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
阅读全文
posted @
2015-04-17 07:20
又岸
阅读(78)
推荐(0)