上一页 1 2 3 4 5 6 7 ··· 11 下一页
摘要: 108 Convert Sorted Array to Binary Search Tree递归解法还是非常直观的class Solution: # @param {integer[]} nums # @return {TreeNode} def sortedArrayToBST(... 阅读全文
posted @ 2015-07-23 02:29 dapanshe 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 117 Populating Next Right Pointers in Each Node II就是 Bibary Tree Level order Traverseclass Solution: # @param root, a tree link node # @return n... 阅读全文
posted @ 2015-07-23 01:45 dapanshe 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 102 Binary Tree Level Order Traversalclass Solution: # @param {TreeNode} root # @return {integer[][]} def levelOrder(self, root): if r... 阅读全文
posted @ 2015-07-23 01:26 dapanshe 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 139 Word Break纯dpclass Solution: # @param s, a string # @param dict, a set of string # @return a boolean def wordBreak(self, s, dict): ... 阅读全文
posted @ 2015-07-22 04:56 dapanshe 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 077 Combinations这道题纯dfs, 但是在 Line 13处做了个剪枝 从84ms 提高到68 ms 1 class Solution: 2 def __init__(self): 3 self.ans = [] 4 5 def combine... 阅读全文
posted @ 2015-07-21 23:31 dapanshe 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 188 Best Time to Buy and Sell Stock IV这道题是我目前为止最得意的一道题了 看看自己的运行时间已经超出所有 Python的解法 自己都醉了class Solution: def __init__(self): self.start = 0 ... 阅读全文
posted @ 2015-07-21 12:22 dapanshe 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 165 Compare Version Numbers用python处理字符串还是比较简单的class Solution: # @param {string} version1 # @param {string} version2 # @return {integer} de... 阅读全文
posted @ 2015-07-21 11:16 dapanshe 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 076 Minimum Window Substring这道题就是用一个dictionary来跟踪有多少还需要Match的字母以及当前需要match的次数。 再用一个queue 来记录哪些字幕被Match了以及他们被match的顺序from collections import defaultdic... 阅读全文
posted @ 2015-07-21 06:44 dapanshe 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 115 Distinct Subsequences这道题是dp, 我定义的dp[i][j] 为用t[:i] 和s[:j] 的disitinct subsequence排列数class Solution: # @param {string} s # @param {string} t ... 阅读全文
posted @ 2015-07-21 04:55 dapanshe 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 129 Sum Root to Leaf Numbers基本就是递归了class Solution: def __init__(self): self.ans = 0 def sumNumbers(self, root): self.help(root, ""... 阅读全文
posted @ 2015-07-20 14:38 dapanshe 阅读(72) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 11 下一页