Jan-14-2020, 05:04 PM
I have to return a simple sum of the most present values in the array, ie [3,5,2,1,2,3,2,2] - > should return 4, because (2,2,2,2).
The array sometimes is crazy focking big, and I cannot pass the execution time limit on the website that im practicing.
My code now is like that:
The array sometimes is crazy focking big, and I cannot pass the execution time limit on the website that im practicing.
My code now is like that:
def birthdayCakeCandles(ar): def count_em(x): fin = ar.count(x) ar.remove(x) return fin return max(map(count_em,ar))ar.remove is to not repeat the iteration for every occurrence of a same value, but it doesnt even feel like a speed up, is it even cached in cpu this way?