# xuelangZF/LeetCode

Switch branches/tags
Nothing to show
Latest commit 473c0c5 Oct 21, 2016
 Failed to load latest commit information. Array Sep 7, 2016 Backtracking Jul 18, 2016 BinarySearch Sep 7, 2016 BitManipulation Aug 23, 2016 BreadthFirstSearch Oct 9, 2016 Combination Jul 29, 2016 DFA Jun 30, 2016 DepthFirstSearch Jul 27, 2016 DivideConquer Aug 30, 2016 DynamicProgramming Oct 21, 2016 Graph Aug 6, 2016 Greedy Oct 9, 2016 HashTable Aug 6, 2016 Heap Aug 6, 2016 Images Aug 6, 2016 LinkedList Sep 7, 2016 Math Jul 26, 2016 Others Aug 1, 2016 Recursion Apr 29, 2016 Stack Jul 9, 2016 String Aug 23, 2016 ToBeOptimized Sep 7, 2016 Tree Oct 9, 2016 TwoPointers Aug 30, 2016 .gitignore Sep 20, 2015 List.md Aug 1, 2016 README.md Aug 1, 2016

• 题目全部来自业内大公司的真实面试
• 不用处理输入输出，精力全放在解决具体问题上
• 题目有丰富的讨论，可以参考别人的思路
• 精确了解自己代码在所有提交代码中运行效率的排名
• 支持多种主流语言：C/C++，Python, Java
• 可以在线进行测试，方便调试

# 不仅是代码

``````class Solution(object):
""" Dynamic programming,  memory DFS search.
The problem exhibits the feature of optimal substructure and overlapping of subproblems.
1. Optimal substructure:  If we want to "rob" maximum amount of money
from current binary tree (rooted at "root"),
we surely hope that we can do the same to its left and right subtrees.
2. Overlapping of subproblems: Computed subproblems repeatedly,
which resulted in bad time performance.
More details can be found as bellows:
https://leetcode.com/discuss/91899/step-by-step-tackling-of-the-problem
"""
cache = {}

def rob(self, root):
if not root:
return 0

if root in self.cache:
return self.cache[root]

# Rob the root node.
money = root.val
if root.left:
money += self.rob(root.left.right) + self.rob(root.left.left)
if root.right:
money += self.rob(root.right.left) + self.rob(root.right.right)

# Do not rob the root node.
self.cache[root] = max(money, self.rob(root.left) + self.rob(root.right))
return self.cache[root]

"""
[]
[3,4,5,1,3,null,1]
[3,2,3,null,3,null,1]
"""
``````

• `Others`：一些暂时没有找到合适分类的题目；
• `ToBeOptimized`：一些解题方案需要优化的题目；
• `Combination`：一些同时用到多个解题思想的综合型题目。

......