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 黑炽 阅读(74) 评论(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) 编辑