Given three integer n, m and k, the task is to find the smallest integer > n such that digit m appears exactly k times in it.
Input: n = 111, m = 2, k = 2
Input: n = 111, m = 2, k = 3
Approach: Start iterating from n + 1 and for each integer i check whether it consists of digit m exactly k times. This way smallest integer > n with digit m occurring exactly k times can be found.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Smallest integer with digit sum M and multiple of N
- Smallest multiple of 3 which consists of three given non-zero digits
- Largest number less than N with digit sum greater than the digit sum of N
- Convert a number of length N such that it contains any one digit at least 'K' times
- Count of Numbers in a Range where digit d occurs exactly K times
- Number formed by adding product of its max and min digit K times
- Least Greater number with same digit sum
- Largest even digit number not greater than N
- Find Nth smallest number that is divisible by 100 exactly K times
- Count of m digit integers that are divisible by an integer n
- Biggest integer which has maximum digit sum in range from 1 to n
- Smallest divisor D of N such that gcd(D, M) is greater than 1
- Smallest integer which has n factors or more
- Number formed after K times repeated addition of smallest divisor of N
- Smallest power of 4 greater than or equal to N
- Count numbers with difference between number and its digit sum greater than specific value
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Smallest N digit number which is a multiple of 5
- Smallest N digit number divisible by N
- Largest and smallest digit of a number
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.