Problem

Submissions

Solution

New

Discuss

2

Difficulty: EASY

Avg. time to solve

10 min

Success Rate

90%

Problem Statement

Suggest Edit

```
Consider the integer N = 45 whose binary representation is 101101. The resulting number formed after swapping each even bit with its adjacent bit to the right will be 30 (011110) in this case.
```

```
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first and only line of each test case contains the integer 'N'.
```

```
For each test case, print the resulting integer formed after swapping each even bit.
Print the output of each test case in a new line.
```

```
You do not need to print anything. It has already been taken care of. Just implement the given function.
```

```
1 <= T <= 10^5
1 <= N <= 10^9
Where 'T' denotes the number of test cases, and 'N' denotes the given integer.
Time Limit: 1 sec
```

```
2
9
2
```

```
6
1
```

```
For the first test case :
The binary representation of 9 is 1001. Here, we will swap the 2nd bit with the 1st bit and the 4th bit with 3rd bit. The resulting binary number will be 0110. Hence, the answer is 6 in this case.
For the second test case :
The binary representation of 2 is 10. Here, we will swap the 2nd bit with the 1st bit. The resulting binary number will be 01 or 1. Hence, the answer is 1 in this case.
```

```
2
7
10
```

```
11
5
```

Console