Solution 1 O(logn) time, n is the first index of the given target number. Solution 2
Tag Archives: Binary Search
Find K Closest Elements – Python 3 (Week 17 – 15)
Time O(logn +k). Space O(1).
Maximum Number in Mountain Sequence – Python 3 (Week 17 – 14)
Last Position of Target – Python 3 ( Week 17 – 13)
Maximum Average Subarray II – Python 3 (Week 14 – 09)
Time O(log (max(nums)-min(nums))*n). Space O(log (max(nums)-min(nums))).
Copy Books – Python 3 ( Week 14 – 08)
Time O(log(end – start) * number of book ). Space O(log(end -start)).
Heaters – Python 3 ( Week 14 – 07)
Time O(log(end)*(n+m)). Space O(logend).
Median of two Sorted Arrays – Python 3 ( Week 11 – 09)
Solution 1 Time O(logmn). Space O(1). Solution 2 Time O(logT *log(m+n))
Find Minimum in Rotated Sorted Array II – Python 3 ( Week 11 – 06)
Time O(logn). Space O(n).
Search in Rotated Sorted Array – Python 3 ( Week 11 – 04)
Solution 1: One BS Time O(logn). Space O(1). Solution 2: 2 BF