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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find any K distinct odd integers such that their sum is equal to N
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- 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
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Count distinct pairs from two arrays having same sum of digits
- Remove two consecutive integers from 1 to N to make sum equal to S
- Minimum digits to be removed to make either all digits or alternating digits same
- Represent (2 / N) as the sum of three distinct positive integers of the form (1 / m)
- Find K distinct positive odd integers with sum N
- Find N distinct integers with zero sum
- Find N distinct integers with sum N
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Check if the sum of digits of number is divisible by all of its digits
- Smallest number with given sum of digits and sum of square of digits
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Add two integers of different base and represent sum in smaller base of the two
- Check if N can be represented as sum of squares of two consecutive integers
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.