<commit_before>package leetcode;

/**
 * https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
 */
public class Problem153 {
    public int findMin(int[] nums) {
        int min = nums[0];
        for (int n : nums) {
            if (n < min) {
                min = Math.min(n, min);
            }
        }
        return min;
    }
}<commit_msg>Solve problem 153 (log n)<commit_after>package leetcode;

/**
 * https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
 */
public class Problem153 {
    public int findMin(int[] nums) {
        return findMin(nums, 0, nums.length-1);
    }
    
    private int findMin(int[] nums, int left, int right) {
        if (left >= right) {
            return nums[left];
        }
        int mid = (left + right) / 2;
        int minLeft = nums[left];
        if (mid-1 >= 0) {
            minLeft = Math.min(minLeft, nums[mid-1]);
        }
        int minRight = nums[right];
        if (mid+1 < nums.length) {
            minRight = Math.min(minRight, nums[mid+1]);
        }
        int min = Math.min(minLeft, Math.min(nums[mid], minRight));
        if (min == nums[mid]) {
            return nums[mid];
        }
        if (minLeft < minRight) {
            return findMin(nums, left, mid-1);
        } else {
            return findMin(nums, mid+1, right);
        }
    }
}
{'fraction_non_alphanumeric': 0.14423076923076922, 'fraction_numerical': 0.014792899408284023, 'mean_word_length': 1.7388663967611335, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5700404', 'n_tokens_mistral': 476, 'n_tokens_neox': 457, 'n_words': 101}