1-line bitset n xor k|0ms beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \nIf n&k<k, it\'s impossible to convert\notherwise count bits in n^k (n xor k)\n# Approac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf n&k<k, it\'s impossible to convert\notherwise count bits in `n^k` (n xor k)\n# Approach\n<!-- Describe your approach to solving the problem. -->\ncount bits in `n^k` is implemented by `bitset<20>(n^k).count()`\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(20)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code||0ms beats 100%\n```\nclass Solution {\npublic:\n    static int minChanges(int n, int k) {\n        return ((n&k)<k)?-1:bitset<20>(n^k).count();\n    }\n};\n```
['Bit Manipulation', 'C++']