Given two input integers `a`

and `b`

, write a method to determine the number of bits required to be swapped to convert `a`

to `b`

.

**Example:**

a = 21, Binary code = 10101 b = 31, Binary code = 11111

`bitSwapRequired(a,b) --> 2`

Need a **hand?** Try out these hints, one at a time.

Use **XOR Bit Manipulation** to count the number of bits that are different between the two numbers.

1. `XOR a`

and `b`

.

2. Count the number of `1`

bits in the output. One way to do is as follows.

a. `Initialize`

the `count`

to `0`

.

b. Start a loop with an initialization expression `c=a^b`

, where `c`

is the iterator. Set the termination expression as `c!=0`

and increment the expression as `c = c &(c-1)`

.

c. Increment the `count`

for each `iteration`

.

d. Return `count`

at the end of the `loop`

.

public int bitSwapRequired(int a, int b) { }

**C**

**Java**

**Python**