We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
N = len(arr)
M = (N+1)*[0]
L = 0
for i in range(0,N):
if arr[i] < i + 1:
continue
if arr[i] >= arr[M[L]] + i - M[L] :
j = L+1
else:
lower = 1
upper = L
while lower <= upper:
mid = int((upper+lower)/2)
if arr[M[mid]] <= arr[i] - i + M[mid]:
lower = mid + 1
else:
upper = mid - 1
j = lower
M[j] = i
if j > L:
L = j
return len(arr)-L
Modify The Sequence
You are viewing a single comment's thread. Return to all comments →
def modifySequence(arr):