left
to 0 and right
to nums.length - 1
.left < right
:
a. Calculate mid
as the midpoint between left
and right
.
b. If nums[mid] > nums[right]
, the inflection point must be to the right of mid
, so set left
to mid + 1
.
c. Else, the inflection point is to the left of mid
, including mid
itself, so set right
to mid
.left
will be the index of the smallest element, return nums[left]
.