swift solution


  • 1
    B
    class Solution {
        func hammingDistance(_ x: Int, _ y: Int) -> Int {
        let c = x ^ y
        return String(c, radix: 2).characters.filter{ $0 == "1"}.count
        }
    }
    

Log in to reply
 

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