Simple Swift Solution
Code
![Screenshot 2025-04-01 at 10.04.24 AM.png](https://assets.leetcode.com/users/images/635c48d6-a0e9-4fe9-9224-feafaa7148f3_1743520190.2347443.png)


# Code
```swift []
class Solution {
    func minChanges(_ n: Int, _ k: Int) -> Int {
        if n < k { return -1 }
        if n == k { return 0 }
        var n = n, k = k, diff = 0
        while n > 0 {
            let nb = n % 2, kb = k % 2
            if kb > nb {
                return -1
            } else if kb < nb {
                diff += 1
            }
            n /= 2
            k /= 2
        }
        return diff
    }
}
```
['Swift']