• Choose the left value
  • Choose the right value
  • Binary search from left to right
left = 0
right = len(nums)
while left < right:
    mid = (left + right) // 2
    if nums[mid] > target: # This condition can be changed according to the problem
        right = mid
    else:
        left = mid+1


if left > 0 and nums[left-1] == target:
    return left-1

return -1

Problems

1011. Capacity To Ship Packages Within D Days