일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 43. Multiply Strings
- Python Implementation
- DWG
- Regular Expression
- 파이썬
- 715. Range Module
- 컴퓨터의 구조
- t1
- LeetCode
- Convert Sorted List to Binary Search Tree
- Python
- 시바견
- attribute
- 운영체제
- Decorator
- data science
- shiba
- Substring with Concatenation of All Words
- 프로그래머스
- 315. Count of Smaller Numbers After Self
- Protocol
- Generator
- iterator
- Class
- Python Code
- 밴픽
- concurrency
- kaggle
- 30. Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
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