Given two integer m and n, the task is to find the sum of distinct digits of both the numbers and print YES if the both the sums are equal else print NO.
Input: m = 2452, n = 9222
The sum of distinct digits of 2452 is 11 (2 + 4 + 5)
And of 9222 is 11 (9 + 2)
Input: m = 121, n = 3035
Approach: Find the sum of unique digits of m and n and store them in sumM and sumN respectively. If sumM = sumN then print YES else print NO.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find any K distinct odd integers such that their sum is equal to N
- Find the first N integers such that the sum of their digits is equal to 10
- Check whether a number can be represented as sum of K distinct positive integers
- Check if N rectangles of equal area can be formed from (4 * N) integers
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Check if product of digits of a number at even and odd places is equal
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Find N distinct integers with zero sum
- Find N distinct integers with sum N
- Find K distinct positive odd integers with sum N
- Number of distinct integers obtained by lcm(X, N)/X
- Represent (2 / N) as the sum of three distinct positive integers of the form (1 / m)
- Find distinct integers for a triplet with given product
- Integers from the range that are composed of a single distinct digit
- Maximum number of distinct positive integers that can be used to represent N
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.