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 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
- Integers from the range that are composed of a single distinct digit
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Count of integers of length N and value less than K such that they contain digits only from the given set
- Number of n-digits non-decreasing integers
- Find the number of integers from 1 to n which contains digits 0's and 1's only
- Numbers having Unique (or Distinct) digits
- Count distinct pairs from two arrays having same sum of digits
- Find three integers less than or equal to N such that their LCM is maximum
- Count positive integers with 0 as a digit and maximum 'd' digits
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.