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