Skip to content
Advertisement

How to check for duplicates with less time in a list over 9000 elements by python

um trying to check whether there are duplicate values exists in an integer list by python . this was successful and I found that the execution time getting higher when the size of the list getting increase. How may I improve the run time of the following logic?

JavaScript

Advertisement

Answer

You could use a set:

JavaScript

EDIT: a faster version, as pointed out in the comments:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement