Problem List

Contains Duplicates

March 02, 2025Go array, hash table, sorting

Fairly straight forward, I am getting the hang of the pattern behind simple hashmap.

Go Solution
func containsDuplicate(nums []int) bool {
    m := make(map[int]bool)

    for _, num := range nums {
        if _,k := m[num]; k {
            return true
        }

        m[num] = true
    }
    return false
}
LeetCode Problem Link