leetcode 98: Search in Rotated Sorted Array II
2013-03-04 11:45
447 查看
Search in Rotated Sorted Array IIApr
20 '12
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.
the time complexity is O(n). this is a example u can not do it in log(n); 11111111111111111113111, target 3. without scan all elements in the array, there is no chance you can find the 3.
20 '12
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.
the time complexity is O(n). this is a example u can not do it in log(n); 11111111111111111113111, target 3. without scan all elements in the array, there is no chance you can find the 3.
public class Solution { public boolean search(int[] A, int target) { // Start typing your Java solution below // DO NOT write main() function // 8,9,10, 1,2,3,4,5,6,7 target 9 for(int i=0;i<A.length;i++) { if(A[i]==target) return true; } return false; } }
相关文章推荐
- leetcode 98: Search in Rotated Sorted Array II
- LeetCode Search in Rotated Sorted Array II
- [LeetCode] Search in Rotated Sorted Array II 解题报告
- LeetCode - Refresh - Search in Rotated Sorted Array II
- [LeetCode] Search in Rotated Sorted Array II [36]
- 81. Search in Rotated Sorted Array II Leetcode Python
- Leetcode 81. Search in Rotated Sorted Array II (Medium) (cpp)
- 【LeetCode】 081. Search in Rotated Sorted Array II
- 【LeetCode从零单刷】Search in Rotated Sorted Array I & II
- [LeetCode]Search in Rotated Sorted Array II
- LeetCode 81. Search in Rotated Sorted Array II
- LeetCode--Search in Rotated Sorted Array II
- leetcode--Search in Rotated Sorted Array II
- 解题报告:LeetCode Search in Rotated Sorted Array II(循环数字查找)
- leetcode_middle_86_81. Search in Rotated Sorted Array II
- LeetCode Search in Rotated Sorted Array II
- LeetCode之Search in Rotated Sorted Array II
- leetcode 【 Search in Rotated Sorted Array II 】python 实现
- LeetCode:Search in Rotated Sorted Array I II
- [LeetCode] Search in Rotated Sorted Array II