2022年7月12日

LeetCode875 爱吃香蕉的珂珂

摘要: LeetCode875 爱吃香蕉的珂珂 二分答案 class Solution: def minEatingSpeed(self, piles: List[int], h: int) -> int: l, r = 1, max(piles) def check(k): time = 0 for c 阅读全文

posted @ 2022-07-12 17:26 solvit 阅读(43) 评论(0) 推荐(0)

LeetCode面试题 16.16. 部分排序

摘要: LeetCode面试题 16.16. 部分排序 记录前缀max和后缀min,采用双指针拟合答案 class Solution: def subSort(self, array: List[int]) -> List[int]: n = len(array) if n == 0: return [-1 阅读全文

posted @ 2022-07-12 16:45 solvit 阅读(33) 评论(0) 推荐(0)

LeetCode剑指 Offer 60. n个骰子的点数

摘要: LeetCode剑指 Offer 60. n个骰子的点数 dp记录状态数量,数学解法会是更快的解法 class Solution: def dicesProbability(self, n: int) -> List[float]: m, p, l, tot = 6, [1, 2, 3, 4, 5, 阅读全文

posted @ 2022-07-12 16:21 solvit 阅读(21) 评论(0) 推荐(0)

LeetCode面试题 08.11. 硬币(完全背包)

摘要: LeetCode面试题 08.11. 硬币 完全背包模板题 class Solution: def waysToChange(self, n: int) -> int: m, p, mod = 4, [1, 5, 10, 25], 1000000007 dp = [0 for i in range( 阅读全文

posted @ 2022-07-12 15:59 solvit 阅读(25) 评论(0) 推荐(0)

导航