You are viewing a single comment's thread. Return to all comments →
count each element divided by 2 note: list.count(ele) is expensive operation
def sockMerchant(n, ar):
s = 0 for i in set(ar): c = 0 for j in ar: if i == j: c += 1 if c >= 2: s += (c // 2) return s
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →
count each element divided by 2 note: list.count(ele) is expensive operation
def sockMerchant(n, ar):