Search Insert Position - LeetCode
Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w
leetcode.com
1
2
3
4
5
6
|
from bisect import bisect_left
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
return bisect_left(nums, target)
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2710. Remove Trailing Zeros From a String (0) | 2023.06.26 |
---|---|
leetcode 2656. Maximum Sum With Exactly K Elements (0) | 2023.06.26 |
leetcode 172. Factorial Trailing Zeroes (0) | 2023.06.26 |
leetcode 9. Palindrome Number (0) | 2023.06.26 |
백준 1152 단어의 개수 (0) | 2023.06.24 |
댓글