![]() |
VOOZH | about |
Given two numbers, the task is to check whether their binary representations are anagrams of each other or not. Two binary numbers are said to be anagrams if they contain the same number of 0s and 1s, irrespective of their order.
Example:
Input: a = 8, b = 4
Output: Yes
Explanation:
This is the most efficient method as it works directly on bit counts without converting to large strings.
Yes
Explanation:
First convert both numbers into 32-bit binary strings using zfill(), then count the number of 0s and 1s in each.
Yes
Explanation:
This approach uses the Counter class from Python’s collections module to count the frequency of 0s and 1s, and then compares the two resulting dictionaries.
Yes
Explanation: