Given two integers A and B, the task is to check whether the given numbers are anagrams of each other or not. Just like strings, a number is said to be an anagram of some other number if it can be made equal to the other number by just shuffling the digits in it.
Input: A = 204, B = 240
Input: A = 23, B = 959
Approach: Create two arrays freqA and freqB where freqA[i] and freqB[i] will store the frequency of digit i in a and b respectively. Now traverse the frequency arrays and for any digit i if freqA[i] != freqB[i] then the numbers are not anagrams of each other else they are.
Below is the implementation of the above approach:
- Check if two strings are k-anagrams or not
- Check if the given array contains all the divisors of some integer
- Check for integer overflow on multiplication
- Check if an integer can be expressed as a sum of two semi-primes
- Given a sequence of words, print all anagrams together | Set 2
- Given a sequence of words, print all anagrams together using STL
- Number of index pairs such that s[i] and s[j] are anagrams
- Given a sequence of words, print all anagrams together | Set 1
- Blum Integer
- Minimum positive integer value possible of X for given A and B in X = P*A + Q*B
- Convert given integer X to the form 2^N - 1
- Replace all ‘0’ with ‘5’ in an input Integer
- Find One's Complement of an Integer
- Find whether a given integer is a power of 3 or not
- Count even and odd digits in an Integer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.