+ 9

Find greatest and smallest digits in a given number

Write a program which takes a number as input and displays the greatest and smallest digits in that number For example, Input:527613 Output: Greatest digit:-->7 Smallest digit:-->1 👇here is mine with Java.... https://code.sololearn.com/cZJZj9eRqby5/?ref=app

25th Feb 2018, 2:14 AM
Nashat
Nashat - avatar
6 Answers
+ 21
one more idea)take digits in an array & use Arrays.sort () , or convert it to a vhar array & do the same ... take element with index 0&(l-1)
25th Feb 2018, 2:44 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
Python one line, following Gaurav's suggestion: https://code.sololearn.com/c55VOqmRTm5U/#py
25th Feb 2018, 3:25 AM
Pedro Demingos
Pedro Demingos - avatar
+ 3
@Ace Thanks!!
25th Feb 2018, 5:47 AM
Nashat
Nashat - avatar
+ 2
https://code.sololearn.com/cepxF85MD0n1/?ref=app
27th Feb 2018, 9:36 AM
Abhimanyu Gupta
Abhimanyu Gupta - avatar
+ 1
https://code.sololearn.com/cCgrV675wS2i/?ref=app New one with a little modification as in the question
27th Feb 2018, 9:14 AM
Nashat
Nashat - avatar