摘要:
思路: 1、nums转set去重,为newlist;2、遍历newlist找出最大频数maxnum;3、遍历newlist针对满足最大频数的元素ch,求其代表的连续子数组: a) 从左往右遍历,找到第一个ch的下标low; b) 从右往左遍历,找到第一个ch的下标high; 将该子数组长度:high 阅读全文
posted @ 2020-04-29 09:27
人间烟火地三鲜
阅读(244)
评论(0)
推荐(0)
摘要:
1 class Solution(object): 2 def findLengthOfLCIS(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 # nums为空 8 if len(nums) == 0: 9 retu 阅读全文
posted @ 2020-04-29 09:17
人间烟火地三鲜
阅读(134)
评论(0)
推荐(0)
摘要:
1 class Solution(object): 2 def checkPossibility(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: bool 6 """ 7 if len(nums) < 2: 8 return True 9 # 阅读全文
posted @ 2020-04-29 09:14
人间烟火地三鲜
阅读(173)
评论(0)
推荐(0)
摘要:
1 class Solution(object): 2 def imageSmoother(self, M): 3 """ 4 :type M: List[List[int]] 5 :rtype: List[List[int]] 6 """ 7 # padding:在原矩阵周围加上一圈非有效数字:- 阅读全文
posted @ 2020-04-29 09:05
人间烟火地三鲜
阅读(193)
评论(0)
推荐(0)
摘要:
代码一思路:遍历nums,每一趟遍历k个元素求和s前,将s清零,不过酱超时。 1 class Solution(object): 2 def findMaxAverage(self, nums, k): 3 """ 4 :type nums: List[int] 5 :type k: int 6 : 阅读全文
posted @ 2020-04-29 09:02
人间烟火地三鲜
阅读(181)
评论(0)
推荐(0)
摘要:
代码一: 1 class Solution(object): 2 def maximumProduct(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 # 降序排列 8 nums.sort(reverse=True) 阅读全文
posted @ 2020-04-29 08:59
人间烟火地三鲜
阅读(171)
评论(0)
推荐(0)
摘要:
代码一: 1 class Solution(object): 2 def canPlaceFlowers(self, flowerbed, n): 3 """ 4 :type flowerbed: List[int] 5 :type n: int 6 :rtype: bool 7 """ 8 if 阅读全文
posted @ 2020-04-29 08:56
人间烟火地三鲜
阅读(134)
评论(0)
推荐(0)
摘要:
思路:将原nums中的元素都读出来,在往新list中加。 1 class Solution(object): 2 def matrixReshape(self, nums, r, c): 3 """ 4 :type nums: List[List[int]] 5 :type r: int 6 :ty 阅读全文
posted @ 2020-04-29 08:52
人间烟火地三鲜
阅读(138)
评论(0)
推荐(0)
摘要:
1 class Solution(object): 2 def arrayPairSum(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 nums.sort() 8 ans = 0 9 for i in range(0 阅读全文
posted @ 2020-04-29 08:48
人间烟火地三鲜
阅读(123)
评论(0)
推荐(0)

浙公网安备 33010602011771号