Trying to do the codality demo: return lowest positive integer not in array,
But I can't get my code to pass the last test and I can't see what the test is. I personally can't get my code to fail, so I must be missing something, here is my python3 code:
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# write your code in Python 3.6
S = set(A)
i = 1
for n in S:
if n < 1:
continue
elif i != n:
break
else:
i += 1
return i
The test that fails is: large_3 chaotic + many -1, 1, 2, 3 (with minus) ✘WRONG ANSWER got 1 expected 10000
I am using set to put the list in order as well as remove multiple possible values. I understand that set puts negative integers in descending order after positive integers.
What is in this test case that is causing my code to fail?
Aucun commentaire:
Enregistrer un commentaire