Determine the number of bits required to flip if you want to convert integer n to integer m.
Given n = 31 (11111), m = 14 (01110), return 2.
class Solution {
/**
*@param a, b: Two integer
*return: An integer
*/
public static int bitSwapRequired(int a, int b) {
// write your code here
int count = 0;
for (int c = a ^ b; c != 0; c = c >>> 1) {
count += c & 1;
}
return count;
}
};