One-line accepted Python solution


  • 1
    J

    Simplest solution I could think of and easy to read.

    def majorityElement(self, nums):
        return max(set(nums), key=nums.count)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.