You are viewing a single comment's thread. Return to all comments →
O(log n) because of sorting of keys in dictionary
def cutTheSticks(arr): freq = {} for i in arr: freq[i] = freq.get(i, 0) + 1 ans = [] sticks_left = len(arr) for num in sorted(freq): ans.append(sticks_left) sticks_left -= freq[num] return ans
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
O(log n) solution Python3 using frequency method
O(log n) because of sorting of keys in dictionary