Created
December 3, 2020 21:25
-
-
Save kingsamadesu/2d50ac06283958d8a66d41b5b17244e1 to your computer and use it in GitHub Desktop.
1323. Maximum 69 Number -with java- (leetcode.com)
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 68.73 % of java submissions. | |
*/ | |
class Solution { | |
public int maximum69Number (int num){ | |
int n = num; | |
int c = 0; | |
int d = 1; | |
while (n>0) { | |
if (n%10 == 6) | |
c = 3*d; | |
n = n/10; | |
d = d*10; | |
} | |
return num + c; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment