标签:style blog color io ar div sp log on
1 public class Solution { 2 public int search(int[] A, int target) { 3 int low=0, high=A.length-1; 4 5 while (low<high) { 6 int mid=(low+high)/2; 7 if (A[mid] < A[high]) { 8 if (target>A[mid] && target<=A[high]) low=mid+1; 9 else high=mid; 10 } else { 11 if (target>=A[low] && target<=A[mid]) high=mid; 12 else low=mid+1; 13 } 14 } 15 16 if (A[low]==target) return low; 17 18 return -1; 19 } 20 }
[LeetCode] Rotated Sorted Array
标签:style blog color io ar div sp log on
原文地址:http://www.cnblogs.com/yuhaos/p/3963343.html