wuyijia

导航

2023年8月28日 #

数组二分查找:35. 搜索插入位置、34. 在排序数组中查找元素的第一个和最后一个位置、69. x 的平方根、367.有效的完全平方数

摘要: 35. 搜索插入位置 1 class Solution: 2 def searchInsert(self, nums: List[int], target: int) -> int: 3 left, right = 0, len(nums)-1 4 5 while left <= right: #左 阅读全文

posted @ 2023-08-28 19:26 小吴要努力 阅读(2) 评论(0) 推荐(0) 编辑

哈希表基础题217. 存在重复元素、389. 找不同、496. 下一个更大元素 I

摘要: 217. 存在重复元素 1 class Solution: 2 def containsDuplicate(self, nums: List[int]) -> bool: 3 #方法1:set去重,直接比较去重之后数组长度 4 if len(set(nums)) != len(nums): 5 re 阅读全文

posted @ 2023-08-28 13:22 小吴要努力 阅读(3) 评论(0) 推荐(0) 编辑