Last active
March 14, 2019 20:56
-
-
Save vijayparashar12/48f3608cd33becedc39d8b91c5208286 to your computer and use it in GitHub Desktop.
Find the smallest number to given Integer with same number of digits: smallestNumber(125) = 100 , smallestNumber(10) = 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public static int smallestNumber(int num) { | |
int count = 0; | |
while (num > 0) { | |
num = num / 10; | |
count++; | |
} | |
return (int) Math.pow(10, count - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment