Leetcode Note: Go - Minimum Bit Flips to Convert Number
Minimum Bit Flips to Convert Number - LeetCode
https://leetcode.com/problems/minimum-bit-flips-to-convert-number/
- Go 言語で取り組んだメモ
回答
Go - Simple Solution (0ms) - Minimum Bit Flips to Convert Number - LeetCode
https://leetcode.com/problems/minimum-bit-flips-to-convert-number/solutions/2477246/go-simple-solution-0ms/
func minBitFlips(start, goal int) int {
// User XOR(^) for finding different bits
// then count result bits
return bits.OnesCount32(uint32(start ^ goal))
}