摘要:
题目描述: 第一次提交: # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None cla 阅读全文
posted @ 2019-07-15 21:49
oldby
阅读(177)
评论(0)
推荐(0)
摘要:
题目描述: 官方题解:双向bfs O(mn) O(mn) from collections import defaultdict class Solution: def __init__(self): self.length = 0 self.all_combo_dict = defaultdict 阅读全文
posted @ 2019-07-15 21:18
oldby
阅读(290)
评论(0)
推荐(0)
摘要:
题目描述: 方法一:正则 class Solution: def isPalindrome(self, s: str) -> bool: return ''.join(re.findall('\w*',s)).lower() == ''.join(re.findall('\w*',s)).lower 阅读全文
posted @ 2019-07-15 19:09
oldby
阅读(107)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def maxProfit(self, prices: List[int], fee: int) -> int: n = len(prices) dp_i_0 = 0 dp_i_1 = float('-inf') for i in range(0 阅读全文
posted @ 2019-07-15 18:55
oldby
阅读(180)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def maxProfit(self, prices: List[int]) -> int: n = len(prices) dp_i_0 = 0 dp_i_1 = float('-inf') dp_pre_0 = 0 for i in rang 阅读全文
posted @ 2019-07-15 18:54
oldby
阅读(220)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def maxProfit(self, k: int, prices: List[int]) -> int: if len(prices) <= 1: return 0 if (k < len(prices) // 2) : dp = [[-pr 阅读全文
posted @ 2019-07-15 18:53
oldby
阅读(239)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def maxProfit(self, prices: List[int]) -> int: dp_i1_0 = 0 dp_i1_1 = float('-inf') dp_i2_0 = 0 dp_i2_1 = float('-inf') for 阅读全文
posted @ 2019-07-15 18:50
oldby
阅读(92)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def maxProfit(self, prices: List[int]) -> int: profit = 0 for i in range(1,len(prices)): tem = prices[i] - prices[i-1] if t 阅读全文
posted @ 2019-07-15 14:18
oldby
阅读(150)
评论(0)
推荐(0)
摘要:
题目描述; 方法一:O(n) O(1) class Solution: def maxProfit(self, prices: List[int]) -> int: minprices = float('inf') maxprofit = 0 for i in prices: if i<minpri 阅读全文
posted @ 2019-07-15 11:38
oldby
阅读(144)
评论(0)
推荐(0)
摘要:
题目描述: 第一次提交:动态规划 class Solution: def minimumTotal(self, triangle: List[List[int]]) -> int: n = len(triangle) for i in range(n-2,-1,-1): for j in range 阅读全文
posted @ 2019-07-15 11:19
oldby
阅读(143)
评论(0)
推荐(0)
摘要:
题目描述: 第一次提交: class Solution: def getRow(self, rowIndex: int) -> List[int]: k = rowIndex pre = [1] + [0] * k res = [1] + [0] * k for i in range(1,k+1): 阅读全文
posted @ 2019-07-15 10:48
oldby
阅读(127)
评论(0)
推荐(0)
浙公网安备 33010602011771号