A short and clear accepted code in Java


  • -1
    W
    public class Solution {
        public int findMin(int[] num) {
            return getMin(num, 0, num.length - 1);
        }
        
        private int getMin(int[] num, int start, int end){
            if(end == start || num[start] < num[end])
                return num[start];
            else{
                int min = (start + end) / 2;
                return Math.min(getMin(num, start, min), getMin(num, min + 1, end));
            }
        }
    }

Log in to reply
 

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