标签:leetcode
https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/
http://blog.csdn.net/linhuanmars/article/details/40449295
public class Solution { public int findMin(int[] num) { // Assume num is not null. return find(num, 0, num.length - 1); } private int find(int[] n, int low, int high) { if (low == high) return n[low]; if (high - low == 1) return Math.min(n[low], n[high]); int mid = low + (high - low) / 2; if (n[low] < n[mid]) { if (n[low] < n[high]) return find(n, low, mid); else return find(n, mid, high); } else { if (n[low] > n[high]) return find(n, low, mid); else return find(n, mid, high); } } }
[LeetCode]153 Find Minimum in Rotated Sorted Array
标签:leetcode
原文地址:http://7371901.blog.51cto.com/7361901/1601235