Search in Rotated Sorted Array

they change the order of condition, so they can merge

Search in Rotated Sorted Array II

当有重复数字,会存在A[mid] = A[start]的情况。此时左半序列A[mid-1 : end]可能是sorted,也可能并没有sorted, 所以当A[mid] = A[start] != target时,无法排除一半的序列,而只能排除掉A[star], 继续searchA[start + 1 : end】在最坏情况下,算法的复杂度退化成了O(n):序列 2 2 2 2 2 2 2 中寻找target = 1。 所以这道题可以只用用一个for - loop 来处理。

results matching ""

    No results matching ""