7 line java solution


  • -1
    E

    Find nums[i] > nums[i+1] condition, if not nums[0] is min value.

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

Log in to reply
 

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