您的位置:首页 > 其它

[Leetcode] 81. Search in Rotated Sorted Array II

2015-03-31 10:42 309 查看
Follow up for "Search in Rotated Sorted Array":

What if duplicates are allowed?

Would this affect the run-time complexity? How and why?

Write a function to determine if a given target is in the array.
public class Solution {
public boolean search(int[] A, int target) {
if(A == null || A.length == 0) return false;
for(int i = 0; i < A.length; i++){
if(A[i] == target) return true;
}
return false;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: