![]() |
VOOZH | about |
Given two non-negative integers a and b. The problem is to check whether the two numbers differ at one bit position only or not.
Examples:
Input : a = 13, b = 9 Output : Yes (13)10 = (1101)2 (9)10 = (1001)2 Both the numbers differ at one bit position only, i.e, differ at the 3rd bit from the right. Input : a = 15, b = 8 Output : No
Approach: Following are the steps:
Output:
Yes
Time Complexity: O(1).
Auxiliary Space: O(1).