Python code using dictionary


  • 0
    C

    """
    dic=dict()
    for element in nums:
    if element in dic:
    dic[element]+=1
    else:
    dic[element]=1
    for key,value in dic.items():
    if value>=len(nums)/2:
    return key
    """


Log in to reply
 

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