Super simple java solution


  • -1
    S

    This solution is easy to understand, but is slower than binary search.

       public class Solution {
            public int findMin(int[] nums) {
                int res = nums[0];
                for (int i = 0; i < nums.length-1; i++) {
                    if (nums[i] > nums[i+1]) {
                        res = nums[i+1];
                        break;
                    }
                }
                return res;
            }
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.