[
binary search
]
BinarySearch 0034 Insertion Index in Sorted List
Problem statement
https://binarysearch.com/problems/Insertion-Index-in-Sorted-List/
Solution
Use binary search, or bisect function in python.
Complexity
It is O(log n)
for time and O(1)
for space.
Code
from bisect import bisect
class Solution:
def solve(self, nums, target):
return bisect(nums, target)