摘要: 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) 编辑
摘要: 双指针法: class Solution: def maxArea(self, height) -> int: if len(height)<=1: return 0 #双指针法 i,j,S=0,len(height)-1,0 while i<j: if height[i]<height[j]: S 阅读全文
posted @ 2019-10-07 22:19 欣姐姐 阅读(213) 评论(0) 推荐(0) 编辑
摘要: ——2019.10.7 阅读全文
posted @ 2019-10-07 21:33 欣姐姐 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 我自己写的超时了。。。。 class Solution: def threeSum(self, nums) : nums.sort() #print(nums) nums1=[] s=[] if nums.count(0)>=3: s.append([0,0,0]) for i in range(l 阅读全文
posted @ 2019-10-07 19:51 欣姐姐 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 执行用时 :80 ms, 在所有 Python3 提交中击败了43.61%的用户 内存消耗 :13.9 MB, 在所有 Python3 提交中击败了5.24%的用户 别人48ms的例子: class Solution: def commonChars(self, A: List[str]) -> L 阅读全文
posted @ 2019-10-07 17:47 欣姐姐 阅读(201) 评论(0) 推荐(0) 编辑