Leetcode
parallelyk
这个作者很懒,什么都没留下…
展开
-
Leetcode 116. Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node.原创 2016-06-28 20:20:19 · 318 阅读 · 0 评论 -
LeetCode 111. Minimum 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 leaf node. /** * Definition for a bina原创 2016-06-21 17:13:24 · 215 阅读 · 0 评论 -
LeetCode 113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 / \原创 2016-06-21 16:51:15 · 198 阅读 · 0 评论 -
Leetcode 102. Binary Tree Level Order Traversal
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 2原创 2016-07-06 21:25:40 · 384 阅读 · 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 [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3原创 2016-07-06 21:01:08 · 309 阅读 · 0 评论 -
Leetcode 104. Maximum Depth of Binary Tree
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. /** * Definition for a bina原创 2016-06-17 16:29:15 · 83 阅读 · 0 评论 -
LeetCode 107. Binary Tree Level Order Traversal II
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,#,#,15,7},原创 2016-06-17 16:26:49 · 367 阅读 · 0 评论 -
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 nodes with keys less than the node's key.Th原创 2016-06-30 21:27:40 · 318 阅读 · 0 评论 -
Leetcode 94. Binary Tree Inorder Traversal
递归的方法: public class Solution { public ArrayList inorderTraversal(TreeNode root) { ArrayList list = new ArrayList(); if(root != null){ list.addAll(inorderTraversal(root原创 2016-06-29 22:17:18 · 244 阅读 · 0 评论 -
Leetcode 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti原创 2016-06-29 20:54:04 · 261 阅读 · 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 of the two subtrees of every node never diffe原创 2016-06-29 20:09:12 · 238 阅读 · 0 评论 -
Leetcode 145. Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solut原创 2016-06-29 20:25:06 · 248 阅读 · 0 评论 -
Leetcode 117. Populating Next Right Pointers in Each Node II
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 still work? Note: You may only use constant原创 2016-06-28 21:12:36 · 296 阅读 · 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. For example: Given the below binary tree andsum =原创 2016-06-28 20:23:04 · 208 阅读 · 0 评论 -
LeetCode 299. Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t原创 2016-06-22 21:19:30 · 272 阅读 · 0 评论