LeetCode 81 Search in Rotated Sorted Array II 题解
1.题目:
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.
题意:
在一个被扭转的有序数组里查找一个数是否存在(可能有重复的数)
2.解题思路:
重复的数会干扰判断,如果头尾重合拿出来单独讨论了TUT,应该有更快的做法。
3.代码
1 |
|