上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 51 下一页
摘要: 思路:用sorted() ,详见:https://www.cnblogs.com/panweiwei/p/12712756.html 1 class Solution(object): 2 def sortArrayByParity(self, A): 3 """ 4 :type A: List[i 阅读全文
posted @ 2020-04-29 09:59 人间烟火地三鲜 阅读(107) 评论(0) 推荐(0)
摘要: 1 class Solution(object): 2 def isMonotonic(self, A): 3 """ 4 :type A: List[int] 5 :rtype: bool 6 """ 7 i = 1 8 while i < len(A): 9 if A[i] == A[i - 1 阅读全文
posted @ 2020-04-29 09:53 人间烟火地三鲜 阅读(233) 评论(0) 推荐(0)
摘要: 1 class Solution(object): 2 def transpose(self, A): 3 """ 4 :type A: List[List[int]] 5 :rtype: List[List[int]] 6 """ 7 hang = len(A) 8 lie = len(A[0]) 阅读全文
posted @ 2020-04-29 09:51 人间烟火地三鲜 阅读(154) 评论(0) 推荐(0)
摘要: 思路: 1、找到seats中第一、最后一个1的位置,分别为:low、high;2、求得最后一个1的后面1的个数recindex(因为要坐最后那么所隔距离就为recindex);3、遍历seats从low到high的元素,用res[]存放每一段连续的0的个数;4、求得res中的最大值leng,通过le 阅读全文
posted @ 2020-04-29 09:49 人间烟火地三鲜 阅读(189) 评论(0) 推荐(0)
摘要: 1 class Solution(object): 2 def flipAndInvertImage(self, A): 3 """ 4 :type A: List[List[int]] 5 :rtype: List[List[int]] 6 """ 7 for i in range(len(A)) 阅读全文
posted @ 2020-04-29 09:47 人间烟火地三鲜 阅读(144) 评论(0) 推荐(0)
摘要: 思路: 1、用空格截cpdomains[i],得到访问次数num和最低级域名IP;2、用‘.’截IP得到words,用domain[]统计顶级域名(即words[-1])和最低级域名(即IP);3、若len(words) == 3说明要统计二级域名(即words[1]+words[2]);4、遍历d 阅读全文
posted @ 2020-04-29 09:43 人间烟火地三鲜 阅读(388) 评论(0) 推荐(0)
摘要: 1 class Solution(object): 2 def dominantIndex(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 m = max(nums) 8 for i in nums: 9 if i = 阅读全文
posted @ 2020-04-29 09:40 人间烟火地三鲜 阅读(179) 评论(0) 推荐(0)
摘要: 1 def minCostClimbingStairs2(self, cost): 2 """ 3 :type cost: List[int] 4 :rtype: int 5 """ 6 cost1 = cost2 = 0 7 for i in cost: 8 cost1, cost2 = i + 阅读全文
posted @ 2020-04-29 09:39 人间烟火地三鲜 阅读(164) 评论(0) 推荐(0)
摘要: 方法一:运用数学技巧 def pivotIndex(self, nums): """ :type nums: List[int] :rtype: int """ sumi = 0 s = sum(nums) for i in range(len(nums)): if 2 * sumi + nums[ 阅读全文
posted @ 2020-04-29 09:35 人间烟火地三鲜 阅读(210) 评论(0) 推荐(0)
摘要: 1 class Solution(object): 2 def isOneBitCharacter(self, bits): 3 """ 4 :type bits: List[int] 5 :rtype: bool 6 """ 7 if len(bits) < 2: 8 return True 9 阅读全文
posted @ 2020-04-29 09:29 人间烟火地三鲜 阅读(218) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 51 下一页