I did two questions today. I didn't solve the second question. I found it too troublesome. I gave up ...... Do it tomorrow when your mind is clear.
The first question is the question in the title. Find the smallest value in a rotating sorting array.
There are two different requirements for this problem, that is, the duplicate element and the duplicate element are not considered.
My solution is to save the first value of the array to the variable and compare the remaining values of the loop array, the first value smaller than the number stored in the variable is the smallest value in the array, which is assigned to the variable and returned.
Both of the two requirements are met. I think it's correct to think about it myself. So the question is, why should we add the difference in this requirement? What is the difference?
This confusion cannot be solved at present. It is placed here for future use.
Find minimum in rotated sorted Array