My simple java solution


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

    Did I miss something? This solution is accepted anyway.


  • 0
    W

    time complexity is not the best!


Log in to reply
 

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