上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 47 下一页
摘要: 题目描述: 方法: class Solution(object): def maxEqualFreq(self, A): count = collections.Counter() freqs = collections.Counter() ans = 1 for i, x in enumerate 阅读全文
posted @ 2019-10-14 10:46 oldby 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法:动态规划O(6∗6∗n∗15) 递归: from functools import lru_cache class Solution: def dieSimulator(self, n, rollMax): MOD = 10 ** 9 + 7 @lru_cache(None) de 阅读全文
posted @ 2019-10-14 10:03 oldby 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]: if not queens:return [] res = 阅读全文
posted @ 2019-10-14 08:59 oldby 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def balancedStringSplit(self, s: str) -> int: if not s:return 0 res = 0 c = {} tmp = None for r in s: if not c: tmp = r c 阅读全文
posted @ 2019-10-14 08:43 oldby 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法:剥洋葱 class Solution: def findMinHeightTrees(self, n: int, edges: List[List[int]]) -> List[int]: if n==1:return [0] e = collections.defaultdict 阅读全文
posted @ 2019-10-12 11:42 oldby 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 方法一:dfs+图 class Solution: def calcEquation(self, equations: List[List[str]], values: List[float], queries: List[List[str]]) -> List[float]: graph = {} 阅读全文
posted @ 2019-10-11 20:31 oldby 阅读(230) 评论(0) 推荐(0) 编辑
摘要: - 题目:130 并查集: class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ f = {} d 阅读全文
posted @ 2019-10-11 20:31 oldby 阅读(504) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:集合 O(N) class Solution: def longestConsecutive(self, nums: List[int]) -> int: nums = set(nums) res = 0 for num in nums: if num-1 not in nums 阅读全文
posted @ 2019-10-11 15:21 oldby 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:动态规划 O(Nk) class Solution: def nthSuperUglyNumber(self, n: int, primes: List[int]) -> int: dp = [1] * n l = [0]*len(primes) for i in range(1 阅读全文
posted @ 2019-10-11 10:33 oldby 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:递归 class Solution: def isUgly(self, num: int) -> bool: if num == 0: return False if num == 1:return True if num % 2 == 0: return self.isUgly 阅读全文
posted @ 2019-10-11 10:01 oldby 阅读(227) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 47 下一页