def majorityElement(self, nums): from collections import Counter n = Counter(nums) return n.most_common(1)
Admittedly, this looks like a cheat. Not entirely sure what the run-time is for the most_common method. Anyone can chime in on this?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.