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:
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.
- 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
- Find Nth smallest number that is divisible by 100 exactly K times
- Largest even digit number not greater than N
- 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 integer which has n factors or more
- Smallest divisor D of N such that gcd(D, M) is greater than 1
- 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 and Largest sum of two n-digit numbers
- Smallest N digit number which is a multiple of 5
- Smallest N digit number divisible by 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 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.