A golang solution


  • 0
    N
    func containsDuplicate(nums []int) bool {
        if len(nums) > 1 {
    		m := make(map[int]struct{})
    
    		for _, v := range nums {
    			_, ok := m[v]
    			if !ok {
    				m[v] = struct{}{}
    			} else {
    				return true
    			}
    		}
    	}
    	return false
    }

Log in to reply
 

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