Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First: iterate just once over data solution in Speedy category for Non-unique Elements by leggewie
### original code from the hints - this works but counts all elements n times, I presum
#def checkio(data):
# return (a for a in data if data.count(a) > 1)
def checkio(data):
occur = dict([x,data.count(x)] for x in set(data)) # iterate over data just once to generate counts
keep = { k for k, v in occur.items() if v > 1 }
return [number for number in data if number in keep]
May 25, 2021