上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 47 下一页
摘要: 题目描述: 自己的提交: class Solution: def processQueries(self, queries: List[int], m: int) -> List[int]: l = [i for i in range(1,m+1)] ans = [] for i in querie 阅读全文
posted @ 2020-04-12 19:33 oldby 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def stringMatching(self, words: List[str]) -> List[str]: def strStr(haystack: str, needle: str) -> int: if not needle:ret 阅读全文
posted @ 2020-04-12 19:27 oldby 阅读(141) 评论(0) 推荐(0) 编辑
摘要: javaO(N) /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class So 阅读全文
posted @ 2020-04-11 23:19 oldby 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:动态规划+二分搜索O(knlogn) O(kn) class Solution: def superEggDrop(self, K: int, N: int) -> int: memo = {} def dp(k, n): if (k, n) not in memo: if n 阅读全文
posted @ 2020-04-11 20:08 oldby 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def cuttingRope(self, n: int) -> int: ans = 0 for m in range(2,max(n//2,3)): j = 1 a = n//m b = n%m for _ in range(b): j 阅读全文
posted @ 2020-04-09 11:40 oldby 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:dfs/bfs class Solution: def movingCount(self, m: int, n: int, k: int) -> int: def digitsum(n): ans = 0 while n: ans += n %10 n//=10 return a 阅读全文
posted @ 2020-04-08 23:28 oldby 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法:从后向前dp class Solution(object): def stoneGameIII(self, A): n = len(A) dp = [-float('inf')] * n for i in range(n-1,-1,-1): dp[i] = max(dp[i], s 阅读全文
posted @ 2020-04-05 19:32 oldby 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交 python: class Solution: def longestDiverseString(self, a: int, b: int, c: int) -> str: res = "" l = [["a", a], ["b", b], ["c", c]] l.sort( 阅读全文
posted @ 2020-04-05 19:07 oldby 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 排序加后缀和 class Solution: def maxSatisfaction(self, satisfaction: List[int]) -> int: satisfaction.sort() t_s = 0 res = 0 for i in satisfaction[::-1 阅读全文
posted @ 2020-04-05 10:31 oldby 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 统计字符奇偶次数即可 class Solution: def canConstruct(self, s: str, k: int) -> bool: if k > len(s): return False c = collections.Counter(s) o = sum(i % 2 阅读全文
posted @ 2020-04-05 10:27 oldby 阅读(79) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 47 下一页