Simple JAVA solution with O(n)


  • 0
    F
        public int findMin(int[] nums) {
        int min = nums[0], cur = nums[nums.length-1];
        if (min > cur) {
            for (int i = nums.length - 1; i > 0; i--) {
                cur = nums[i];
                if (cur <= min) {
                    min = cur;
                } else {
                    break;
                }
            }
        }
        return min;
    }

Log in to reply
 

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