摘要: 执行用时 :168 ms, 在所有 Python3 提交中击败了73.83%的用户 内存消耗 :19.1 MB, 在所有 Python3 提交中击败了19.02%的用户 别人32ms的范例: class Solution: def containsDuplicate(self, nums: List 阅读全文
posted @ 2019-10-08 20:55 欣姐姐 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 执行用时 :168 ms, 在所有 Python3 提交中击败了27.45%的用户 内存消耗 :14.9 MB, 在所有 Python3 提交中击败了5.18%的用户 看看人家40ms的范例: class Solution: def rotate(self, nums: List[int], k: 阅读全文
posted @ 2019-10-08 20:46 欣姐姐 阅读(142) 评论(0) 推荐(0) 编辑
摘要: class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: a=nums.count(target) if a==0: return [-1,-1] else: d=nums.index(targ 阅读全文
posted @ 2019-10-08 17:29 欣姐姐 阅读(202) 评论(0) 推荐(0) 编辑
摘要: ——2019.10.8 我太蠢了,当时并不知道什么是logn级别,就暴力瞎写,啥也不懂,十分尴尬。 二分法,确定边界 public int search(int[] nums, int target) { //未知位置发生旋转,如何确定是哪个位置发生的? //二分法如何使用,如何判断边界? int 阅读全文
posted @ 2019-10-08 17:05 欣姐姐 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 自己做出来效果并不是很好: class Solution: def removeDuplicates(self, nums) -> int: i=0 while i<len(nums)-2: j,k=i+1,i+2 if nums[i]==nums[j]: if nums[j]==nums[k]: 阅读全文
posted @ 2019-10-08 16:50 欣姐姐 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 双指针: class Solution: def removeDuplicates(self, nums) -> int: if len(nums)<2: return len(nums) i,j=0,1 while j<len(nums): if nums[i]==nums[j]: nums.po 阅读全文
posted @ 2019-10-08 16:30 欣姐姐 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 我自己做了一上午还是有错误,参考了别人的,一目了然。 双指针!!! class Solution: def fourSum(self, nums, target: int): n = len(nums) if n < 4: return [] nums.sort() res = [] for i i 阅读全文
posted @ 2019-10-08 16:09 欣姐姐 阅读(157) 评论(0) 推荐(0) 编辑
摘要: class Solution: def trap(self, height) -> int: if len(height)<2: return 0 H=max(height) I=height.index(H) S=H*len(height) #print(S) S_1=sum(height) #p 阅读全文
posted @ 2019-10-08 10:17 欣姐姐 阅读(190) 评论(0) 推荐(0) 编辑