Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add leetcode 34 一行 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
cy69855522 merged 1 commit into cy69855522:master from Lebhoryi:master
Feb 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,19 @@ class Solution:
i = (bisect.bisect_left(nums[k:] + nums[:k], target) + k) % max(len(nums), 1)
return i if nums and nums[i] == target else -1
```

## [34. 在排序数组中查找元素的第一个和最后一个位置](https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/)

- 用自带的bisect函数,一行

```python3
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
# if not nums or target not in nums: return [-1, -1]
return [bisect.bisect_left(nums, target), bisect.bisect_right(nums, target)-1] \
if nums and target in nums else [-1, -1]
```

## [35. Search Insert Position 1行](https://leetcode.com/problemset/all/?search=35)
```python
class Solution:
Expand Down

AltStyle によって変換されたページ (->オリジナル) /