LeetCode 562. Longest Line of Consecutive One in Matrix(java)

Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal.Exampl...

2018-02-11 15:58:57

阅读数:56

评论数:0

LeetCode 312. Burst Balloons(java)

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloo...

2018-01-27 10:46:05

阅读数:29

评论数: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

阅读数:17

评论数:0

LeetCode 22. Generate Parentheses(java)

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ ...

2018-01-21 06:25:52

阅读数:25

评论数: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

阅读数:30

评论数:0

递归优化小技巧:用hashmap或者数组来预存sub-result以加快速度

技巧如题,先用hashmap或者数组来保存某些已经算好的,之后可能会重复用到的子问题的答案,这样在每次递归之前先判断,如果是存在在map里的,就直接取value返回即可。可以大大提高递归的效率。 例一:LeetCode 140. Word Break II Given a non-empty ...

2018-01-21 04:09:11

阅读数:48

评论数: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

阅读数:15

评论数:0

LeetCode 70. Climbing Stairs(java)

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl...

2018-01-16 11:56:09

阅读数:12

评论数: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

阅读数:42

评论数:0

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