class Solution {
public int search(int[] nums, int target) {
int n = nums.length;
if (n == 1) {
return target == nums[0] ? 0 : -1;
}
int l1 = 0;
int l2 = 0;
for (int i = 0; i < n - 1; i++) {
if (nums[i] > nums[i + 1]) {
l2 = i;
break;
}
}
int index1 = search(nums, l1, l2, target);
int index2 = search(nums, l2 + 1, n - 1, target);
if (index1 != -1) {
return index1;
}
if (index2 != -1) {
return index2;
}
return -1;
}
}
标签:search,return,target,nums,33,int,l2,数组,排序
From: https://www.cnblogs.com/eiffelzero/p/16864693.html