Given a number N. The task is to find the largest and the smallest digit of the number.
Input : N = 2346
Output : 6 2
6 is the largest digit and 2 is samllest
Input : N = 5
Output : 5 5
Approach: An efficient approach is to find all digits in the given number and find the largest and the smallest digit.
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.
- Queries for the smallest and the largest prime number of given digit
- Smallest and Largest N-digit number starting and ending with N
- Smallest and Largest sum of two n-digit numbers
- Smallest and Largest N-digit perfect squares
- Largest and Smallest N-digit Hexadecimal Numbers
- Smallest and Largest N-digit perfect cubes
- Largest and Smallest N-digit Octal Numbers
- Largest number less than N with digit sum greater than the digit sum of N
- Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
- Smallest K digit number divisible by X
- Smallest N digit number divisible by N
- Smallest N digit number which is a multiple of 5
- Largest value of x such that axx is N-digit number of base b
- Largest even digit number not greater than N
- Largest N digit number in Base B
- Largest K digit number divisible by X
- C++ Program for Smallest K digit number divisible by X
- Smallest n digit number divisible by given three numbers
- C++ Program for Largest K digit number divisible by X
- Largest N digit number divisible by given three numbers
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.