摘要: class Solution(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 length = len(nums) if length == 1: return 阅读全文
posted @ 2019-03-17 12:55 AceKo 阅读(149) 评论(0) 推荐(0)
摘要: #coding=utf-8# 1# 对状态的定义 : 考虑偷取[x...n-1]范围里的房子class Solution1(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: ret 阅读全文
posted @ 2019-03-17 12:54 AceKo 阅读(98) 评论(0) 推荐(0)
摘要: #coding=utf-8#递归class Solution1(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ return self.tryRob(nums,0) # 考虑抢劫nums[index,.. 阅读全文
posted @ 2019-03-17 12:53 AceKo 阅读(123) 评论(0) 推荐(0)
摘要: class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ if not prices: return 0 buy = [0 for i in range(len(p 阅读全文
posted @ 2019-03-17 12:52 AceKo 阅读(377) 评论(0) 推荐(0)
摘要: class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ if not prices: return 0 buy = -prices[0] sell = 0 for 阅读全文
posted @ 2019-03-17 12:50 AceKo 阅读(334) 评论(0) 推荐(0)
摘要: class Solution1(object): def minimumTotal(self, triangle): """ :type triangle: List[List[int]] :rtype: int """ self.dp(triangle) # i # i , i+1 def dp( 阅读全文
posted @ 2019-03-17 12:49 AceKo 阅读(237) 评论(0) 推荐(0)
摘要: #coding=utf-8class Solution1(object): def numDecodings(self, s): """ :type s: str :rtype: int """ if not s: return return self.decode(s) pass def deco 阅读全文
posted @ 2019-03-17 12:45 AceKo 阅读(146) 评论(0) 推荐(0)
摘要: class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ self.memo = [-1 for i in range(n+1)] return self.calcWays1(n) def c 阅读全文
posted @ 2019-03-17 12:44 AceKo 阅读(172) 评论(0) 推荐(0)
摘要: #coding=utf-8# 按递归的逆顺序 从底向上class Solution1(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ self.m = len(grid) sel 阅读全文
posted @ 2019-03-17 12:41 AceKo 阅读(200) 评论(0) 推荐(0)
摘要: #coding=utf-8# 递归# dfsclass Solution1(object): def uniquePathsWithObstacles(self, obstacleGrid): """ :type obstacleGrid: List[List[int]] :rtype: int " 阅读全文
posted @ 2019-03-17 12:40 AceKo 阅读(153) 评论(0) 推荐(0)