mirror of https://github.com/doocs/leetcode.git
|
…
|
||
|---|---|---|
| .. | ||
| README.md | ||
| README_EN.md | ||
| Solution.java | ||
README_EN.md
05.06. Convert Integer
Description
Write a function to determine the number of bits you would need to flip to convert integer A to integer B.
Example1:
Input: A = 29 (0b11101), B = 15 (0b01111) Output: 2
Example2:
Input: A = 1,B = 2
Output: 2
Note:
-2147483648 <= A, B <= 2147483647
Solutions
Python3
Java
class Solution {
public int convertInteger(int A, int B) {
return Integer.bitCount(A ^ B);
}
}
...