摘要: from typing import Listclass Solution: # 错误的思路,会超时。 def maxProfit1(self, prices: List[int]) -> int: if len(prices) <= 1:return 0 # 小于等于一天没法交易买和卖 # 进行双 阅读全文
posted @ 2020-06-30 18:25 月为暮 阅读(248) 评论(0) 推荐(0) 编辑
摘要: from typing import Listclass Solution: def minimumTotal1(self, triangle: List[List[int]]) -> int: return self.dfs(triangle,0,0,len(triangle),0) # 深搜的做 阅读全文
posted @ 2020-06-30 17:52 月为暮 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 这道题和第118题是一样的,需要注意这道题目对行数的要求 # 定义一个列表,用来存放数据 num_list = [] for index1 in range(rowIndex + 1): # 每一行要先添加一个空列表 num_list.append([]) # 注意这里的for循环的范围 for i 阅读全文
posted @ 2020-06-30 16:20 月为暮 阅读(186) 评论(0) 推荐(0) 编辑
摘要: from typing import Listclass Solution: def generate(self, numRows: int) -> List[List[int]]: # 定义一个列表,用来存放数据 num_list = [] for index1 in range(numRows) 阅读全文
posted @ 2020-06-30 16:15 月为暮 阅读(229) 评论(0) 推荐(0) 编辑
摘要: # Definition for a Node.class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val s 阅读全文
posted @ 2020-06-30 15:55 月为暮 阅读(205) 评论(0) 推荐(0) 编辑