I'm trying to solve the almost increasing sequence problem. The goal is to see if an array is a strictly increasing sequence if no more than one item is removed. I'm trying to accomplish this with the pop()
method. Here is what I have so far:
def almostIncreasingSequence(sequence):
new_seq = sequence
output = False
for i in range(len(sequence)):
new_seq.pop(i)
if all(i < j for i, j in zip(new_seq, new_seq[1:])):
output = True
else:
output = False
return output
I'm basically popping the element at index i and then assigning a boolean value to output
depending on whether it is strictly increasing or not but this is the error I'm getting:
Traceback (most recent call last):
main.py3 in the pre-written template, in getUserOutputs
userOutput = _runmaxat(testInputs[i])
main.py3 in the pre-written template, in _runmaxat
return almostIncreasingSequence(*_fArgs_mksftvlwcpxn)
main.py3 on line 6, in almostIncreasingSequence
sequence.pop(i)
IndexError: pop index out of range
Sample tests: 0/19