标签:意义 解法 and 部分 for int 题目 algorithm turn
class Solution { private: int searchCore(vector<int>nums,int begin,int end,int target){ if(begin>end||begin<0||end>=nums.size()) return -1; if(nums[begin]==nums[end] && nums[begin]==target) return begin; if(nums[begin]<=nums[end]&&(nums[begin]>target||nums[end]<target)) return -1; int mid=(end-begin)/2+begin; int l=searchCore(nums,begin,mid,target); int r=searchCore(nums,mid+1,end,target); if(l!=-1) return l; else return r; } public: int search(vector<int>& nums, int target) { int res=-1; res=searchCore(nums,0,nums.size()-1,target); return res; } };
leetcode [33] Search in Rotated Sorted Array
标签:意义 解法 and 部分 for int 题目 algorithm turn
原文地址:https://www.cnblogs.com/xiaobaituyun/p/10589908.html