Skip to content

Instantly share code, notes, and snippets.

@kingsamadesu
Created December 3, 2020 21:25
Show Gist options
  • Save kingsamadesu/2d50ac06283958d8a66d41b5b17244e1 to your computer and use it in GitHub Desktop.
Save kingsamadesu/2d50ac06283958d8a66d41b5b17244e1 to your computer and use it in GitHub Desktop.
1323. Maximum 69 Number -with java- (leetcode.com)
/*
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