2020年10月23日

摘要: 1 from random import randint 2 3 def factors(num, fact = []): 4 #每次从2开始查找因数 5 for i in range(2, int(num**0.5) + 1): 6 if num % i == 0: 7 fact.append(i 阅读全文

posted @ 2020-10-23 15:04 黑炽 阅读(1390) 评论(2) 推荐(0) 编辑

摘要: 1 def C(n, i): 2 cache2 = dict() 3 def f(n, i): 4 if n == i or i == 0: 5 return 1 6 elif (n, i) not in cache2: 7 cache2[(n, i)] = f(n - 1, i) + f(n - 阅读全文

posted @ 2020-10-23 09:45 黑炽 阅读(925) 评论(0) 推荐(0) 编辑

2020年10月22日

摘要: 嗯。。。如果直接在文章里面找的话,会很麻烦。。。反正我自己是没找到的。 可以在两个数据库中找到需要的文章,之后把文章名字复制,用百度学术搜索 或者 Google学术搜索 找到之后,点击搜索结果下面的引用即可 另,推荐一个网址,虫部落。网址: https://search.chongbuluo.com 阅读全文

posted @ 2020-10-22 15:19 黑炽 阅读(2015) 评论(0) 推荐(0) 编辑

摘要: 1 def fib(n): 2 a, b = 1, 1 3 while a < n: 4 print(a, end = ' ') 5 a, b = b, a + b 6 print() 7 fib(1000) 阅读全文

posted @ 2020-10-22 13:19 黑炽 阅读(2096) 评论(0) 推荐(0) 编辑

2020年10月21日

摘要: 1 class Solution(object): 2 def isLongPressedName(self, name, typed): 3 """ 4 :type name: str 5 :type typed: str 6 :rtype: bool 7 """ 8 i, j = 0, 0 9 阅读全文

posted @ 2020-10-21 22:53 黑炽 阅读(126) 评论(0) 推荐(0) 编辑

2020年10月18日

摘要: 1 class Solution: 2 def findErrorNums(self, nums: List[int]) -> List[int]: 3 nums = sorted(nums) 4 result = result_repeat = 0 5 for i in range(1, len( 阅读全文

posted @ 2020-10-18 15:27 黑炽 阅读(80) 评论(0) 推荐(0) 编辑

摘要: 1 class Solution: 2 def maximumProduct(self, nums: List[int]) -> int: 3 nums_sorted = sorted(nums) 4 mul_max_positive = nums_sorted[-1] * nums_sorted[ 阅读全文

posted @ 2020-10-18 10:22 黑炽 阅读(75) 评论(0) 推荐(0) 编辑

摘要: 1 class Solution: 2 def thirdMax(self, nums: List[int]) -> int: 3 nums_set = set(nums)#先转化为集合,那么就解决了重复问题 4 data_sorted = sorted(nums_set)#然后排序,返回值是列表 阅读全文

posted @ 2020-10-18 10:09 黑炽 阅读(73) 评论(0) 推荐(0) 编辑

摘要: 1 class Solution: 2 def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int: 3 ''' 4 首先找到规律 5 若下一个开始的时间 减去上一个开始的时间,若结果大于 持续的时间,那么就 阅读全文

posted @ 2020-10-18 09:49 黑炽 阅读(79) 评论(0) 推荐(0) 编辑

摘要: 1 class Solution: 2 def findMaxConsecutiveOnes(self, nums: List[int]) -> int: 3 return max(map(len, ''.join(map(str, nums)).split('0'))) join() 方法用于将序 阅读全文

posted @ 2020-10-18 09:07 黑炽 阅读(82) 评论(0) 推荐(0) 编辑