No Repeats please Help [Solved]

No Repeats please Help [Solved]
0.0 0

#1

Hi:
I came up with an algorithm for the challenge No Repeats please.
It can’t pass any tests while I always can get correct answer by manually running it. I am wondering if it is because it is so slow that I can’t pass the tests.
Below is my code. Anyone can help me please. Thanks!


#2

It’s probably because you have a global variable count.


#3

Yes. You are right.
I changed count to a local variable and it works. Thanks!
But do you know why the global variable doesn’t work?


#4

See the first comment here: https://github.com/FreeCodeCamp/FreeCodeCamp/issues/9199

The reason being that we run multiple test cases in on the code, using a global var like this persists the last value and hence the test cases fail.