Skip to content

Latest commit

 

History

History
61 lines (35 loc) · 883 Bytes

README_EN.md

File metadata and controls

61 lines (35 loc) · 883 Bytes

中文文档

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:

  1. -2147483648 <= A, B <= 2147483647

Solutions

Python3

Java

class Solution {
    public int convertInteger(int A, int B) {
        return Integer.bitCount(A ^ B);
    }
}

...