posted @ 2020-10-23 21:16
随笔分类 - leetcode
摘要:1 class Solution: 2 def sortArray(self, nums: List[int]) -> List[int]: 3 self.quickSort(nums, 0, len(nums)-1) 4 return nums 5 6 def quickSort(self, nu
阅读全文
摘要: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
摘要: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
摘要: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
摘要: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
摘要:1 class Solution: 2 def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int: 3 ''' 4 首先找到规律 5 若下一个开始的时间 减去上一个开始的时间,若结果大于 持续的时间,那么就
阅读全文
posted @ 2020-10-18 09:49
摘要: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
浙公网安备 33010602011771号