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:
- 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
- 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
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Next Number with distinct digits
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Find the number of integers from 1 to n which contains digits 0's and 1's only
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.