일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Regular Expression
- 43. Multiply Strings
- Python
- 밴픽
- 715. Range Module
- 컴퓨터의 구조
- Python Implementation
- LeetCode
- concurrency
- iterator
- 프로그래머스
- Class
- data science
- 파이썬
- Convert Sorted List to Binary Search Tree
- DWG
- 시바견
- Substring with Concatenation of All Words
- 운영체제
- 30. Substring with Concatenation of All Words
- t1
- attribute
- kaggle
- 315. Count of Smaller Numbers After Self
- Protocol
- Decorator
- Generator
- 109. Convert Sorted List to Binary Search Tree
- shiba
- Python Code
Archives
- Today
- Total
목록34. Find First and Last Position of Element in Sorted Array (1)
Scribbling
34. Find First and Last Position of Element in Sorted Array
class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: return self.binary_search(nums, 0, len(nums)-1, target) def binary_search(self, nums, left, right, target): if left > right: return [-1, -1] mid = (left + right) // 2 mid_val = nums[mid] if mid_val > target: return self.binary_search(nums, left, mid-1, target) elif mid_val < target: return self.binary_search(nums, ..
Computer Science/Coding Test
2021. 9. 11. 22:31