A Simple Recursive Solution in Java


  • -1
    H
        public int findMin(int[] nums) {
            if (nums == null || nums.length == 0) {
                return -1;
            }
            return this.find(nums, 0, nums.length - 1);
        }
        public int find(int[] nums, int start, int end) {
            if (start == end) {
                return nums[start];
            }
            int mid = start + (end - start) / 2;
            return Math.min(this.find(nums, start, mid), this.find(nums, mid + 1, end));
        }

Log in to reply
 

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