Swift solution


  • 0
    class Solution {
        func missingNumber(_ nums: [Int]) -> Int {
            var result = 0
            var i = 0
            
            while i < nums.count {
                result = result ^ i ^ nums[i]
                i += 1
            }
            
            return result ^ i
        }
    }
    

Log in to reply
 

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