您的位置:首页 > 其它

leetcode - Search in Rotated Sorted Array II

2013-11-05 22:48 429 查看
class Solution {
public:
bool search(int A[], int n, int target) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if (n<=0) // cannot decide which side target should be, so O(n)
return -1;
for (int i=0; i<n; i++)
if (A[i]==target)
return true;
return false;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: