My accepted swift code


  • 1
    A

    class Solution {

    func containsDuplicate(nums: [Int]) -> Bool {

    let numsList = nums.sort()
    for i in 0 ..< nums.count {
        if i + 1 < nums.count{
            if numsList[i] == numsList[i+1] {
                return true
            }
        }
        
    }
    return false
    

    }
    }


Log in to reply
 

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