You are viewing a single comment's thread. Return to all comments →
def sockMerchant(n, ar): # Write your code here ar.sort() _dict = {}
for i in ar: if(i in _dict.keys() ): _dict[i] += 1 else: _dict[i] = 1 pair = 0 for j in _dict: if(_dict[j] >= 2): if(_dict[j] == 2): pair+=1 else: if (_dict[j] % 2 == 0): pair+= (_dict[j] / 2) else: pair+= ( (_dict[j] - 1 ) / 2) return int(pair)
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 →
def sockMerchant(n, ar): # Write your code here ar.sort() _dict = {}