We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6721b7f commit 01cd6d1Copy full SHA for 01cd6d1
README.md
@@ -415,6 +415,19 @@ class Solution:
415
i = (bisect.bisect_left(nums[k:] + nums[:k], target) + k) % max(len(nums), 1)
416
return i if nums and nums[i] == target else -1
417
```
418
+
419
+## [34. 在排序数组中查找元素的第一个和最后一个位置](https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/)
420
421
+- 用自带的bisect函数,一行
422
423
+```python3
424
+class Solution:
425
+ def searchRange(self, nums: List[int], target: int) -> List[int]:
426
+ # if not nums or target not in nums: return [-1, -1]
427
+ return [bisect.bisect_left(nums, target), bisect.bisect_right(nums, target)-1] \
428
+ if nums and target in nums else [-1, -1]
429
+```
430
431
## [35. Search Insert Position 1行](https://leetcode.com/problemset/all/?search=35)
432
```python
433
class Solution:
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments