Alice has two numbers, 'X' and 'Y'. He is asked to perform the following operations any number of times.
Alice adds 1 to 'X' if 'X' is odd. Alice adds 2 to 'X' if 'X' is even. Will he be able to make 'X' equal to 'Y'?
Return 1 if 'X' can be made equal to 'Y' using the above operations any number of times(possibly 0) and 0 otherwise.
Note: Assume 1-based indexing.
Let 'X' = 3 and 'Y' = 6, Alice adds 1 to 'X' since 'X' is odd. Now 'X' will become 4. Then, Alice will add 2 to 'X', since 'X' is even, and it will become 6. 'X' becomes equal to 'Y'. Hence we will return 1 as the answer.
The first line contains an integer 'T', which denotes the number of test cases.
For every test case:-
The first line contains two integers, 'X' and 'Y', the variables mentioned above.
Output Format:-
For each test case, Return 1 if 'X' can be made equal to 'Y' using the above operations any number of times(possibly 0) and 0 otherwise.
Note:-
You don’t need to print anything. Just implement the given function.
1 <= 'T' <= 10
1 <= 'X', 'Y' <= 10^9
Time Limit: 1 sec
2
4 8
1 1
1
1
First test case:-
In 1st operation, Alice will add 2 to 'X' as 'X' is even. Now, 'X' is 6. Again, in the 2nd operation, Alice will add 2 to 'X'. Now 'X' is 8, which is equal to 'Y'. So, the answer is 1.
Second test case:-
'X' is already equal to 'Y'. So, the answer is 1.
2
4 9
7 8
0
1
Look for the parity of 'y'.
Approach:-
If 'x' > 'y', 'x' can never be made equal to 'y'.
If 'y' is even, we can always make 'x' equal to 'y' by performing some number of operations.
If 'y' is odd, Let's take two cases:
So, when 'y' is odd, it is impossible to make 'x' equal to 'y' except if 'x' is already equal to 'y'.
Algorithm:-
O(1),
since we are only using the if-else condition, it takes O(1) time. Hence, The overall time complexity is of the order O(1).
O(1).
since we are not using any variable, which will take O(1) space. so, the space complexity is O(1).