Find minimum in rotated sorted Array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.