We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I tried a different approach using Collections.Counter and a comprehension list, returning its first value if exists. Additionally, added an optional parameter that allows to change the amount of repeats that we are looking for.
fromcollectionsimportCounterdeflonelyinteger(a,repeats=1):# Write your code hereresponse=[keyforkey,valueinCounter(a).items()ifvalue==repeats]returnresponse[0]iflen(response)>0else''
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
PYTHON3
I tried a different approach using Collections.Counter and a comprehension list, returning its first value if exists. Additionally, added an optional parameter that allows to change the amount of repeats that we are looking for.