摘要: from typing import List# 用动态规划的写法来写题。# 每一天都有五种情况发生,#1,今天买入,2,今天卖出,3今天是冷冻期,4,今天不买入也不卖出(没有持有股票)5,今天不买入也不卖出(持有股票)class Solution: def maxProfit(self, pric 阅读全文
posted @ 2020-07-14 19:22 月为暮 阅读(260) 评论(0) 推荐(0) 编辑
摘要: # 动态规划的解法,参考别人的。from typing import Listclass Solution: def respace(self, dictionary: List[str], sentence: str) -> int: d = {}.fromkeys(dictionary,"heh 阅读全文
posted @ 2020-07-14 16:15 月为暮 阅读(275) 评论(0) 推荐(0) 编辑
摘要: from typing import List# 这道题比较容易,遍历一遍k + 1就好了,# 可以算出所有的结果,但是会有重复值,因此需要将重复值排除# 同时避免超市class Solution: def divingBoard(self, shorter: int, longer: int, k 阅读全文
posted @ 2020-07-14 15:42 月为暮 阅读(180) 评论(0) 推荐(0) 编辑