Bottom up专题六 LeetCode 250. Count Univalue Subtrees

LeetCode 250. Count Univalue Subtrees Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree...

2019-01-17 10:09:21

阅读数:6

评论数:0

Bottom up专题五 LeetCode 333. Largest BST Subtree

Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. No...

2019-01-17 09:54:02

阅读数:77

评论数:0

Bottom up专题四 LeetCode 113. Path Sum II

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. Note: A leaf is a no...

2019-01-17 08:46:15

阅读数:109

评论数:0

Bottom up专题三 LeetCode 236. Lowest Common Ancestor of a Binary Tree

LeetCode 236. Lowest Common Ancestor of a Binary Tree Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Acco...

2019-01-17 07:05:59

阅读数:96

评论数:0

Bottom up专题二 LeetCode 98. Validate Binary Search Tree

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...

2019-01-17 06:04:26

阅读数:81

评论数:0

Bottom up专题一 LeetCode124. Binary Tree Maximum Path Sum

Bottom up的方法指的就是把每一个node上需要存的数据都记录在一个新建的类里,dfs的时候,在每一个节点做本节点的操作,然后创建一个新建类的对象,把对象里在此节点应该记录的数据都赋值,然后返回本节点即可。最后返回到root的时候,直接取出root节点的对象里需要的值即可。 LeetCode...

2019-01-17 05:26:05

阅读数:78

评论数:0

DP动态规划专题三 :LeetCode 95. Unique Binary Search Trees II

Unique Binary Search Trees II Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n. Example: Inp...

2018-12-30 13:03:39

阅读数:41

评论数:0

LeetCode 301. Remove Invalid Parentheses

Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may con...

2018-12-29 06:33:50

阅读数:12

评论数:0

打印树的所有路径

第一题是给了一棵树 打出所有从root到leave的路径 思路:递归DFS的方法,每次向两边孩子走,直到走到叶子节点为止。 public List<List<Integer>> res rightSid...

2018-12-28 03:27:06

阅读数:10

评论数:0

LeetCode 113. Path Sum II(java)

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 su...

2018-03-07 09:45:53

阅读数:68

评论数:0

LeetCode 112. Path Sum(java)

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.F...

2018-03-07 09:41:29

阅读数:52

评论数:0

LeetCode 95. Unique Binary Search Trees II

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 ...

2018-01-25 03:08:43

阅读数:42

评论数:0

LeetCode 96. Unique Binary Search Trees(java)

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...

2018-01-24 07:54:50

阅读数:40

评论数:0

LeetCode 617. Merge Two Binary Trees(java)

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are ...

2018-01-21 06:06:11

阅读数:63

评论数:0

LeetCode 337. House Robber III(java)

The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each ho...

2018-01-21 05:21:50

阅读数:82

评论数:0

LeetCode 226. Invert Binary Tree(java)

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1解法一:递归解,对于每一个节点,其左孩子变成右孩子,右孩子变...

2018-01-20 07:31:21

阅读数:34

评论数:0

LeetCode 687. Longest Univalue Path(java)

Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the ro...

2018-01-19 09:17:48

阅读数:133

评论数:0

LeetCode 104. Maximum Depth of Binary Tree(java)

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 l...

2018-01-15 08:52:59

阅读数:55

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭