I'm trying to solve this problem:Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array. I came up with this code:
def almostIncreasingSequence(seq):
count_2 = 0
for element in seq:
count = 0
seq.remove(element)
for i in range(len(seq)-1):
if seq[i] < seq[i+1]:
count += 1
else:
break
if count == len(seq):
return True
else:
seq = [element]+ seq
count_2 += 1
if count_2 == len(seq):
return False
The problem is that when I give an input, the function doesn't do anything.for example in the interactive shell:
>>>print(almostIncreasingSequence([10,1,2,3,4,5]))
>>None
and if I don't use print:
>>>almostIncreasingSequence([10,1,2,3,4,5])
>>>
it returns nothing,it should return True for this special sequence.