Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
When num[mid] == num[tail], we need to linearly move the pointer. The worst case complexity is O(n), but the average will still be better than simple linear search.
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
When num[mid] == num[tail], we need to linearly move the pointer. The worst case complexity is O(n), but the average will still be better than simple linear search.
Comments
Post a Comment