My Solution (StringBuilder)
1 | class Solution { |
Remarks:
- Be careful of
int
boundary; usetry
andcatch
to hold big numbers error. - Java get char:
str.valueOf(num);
- Java convert to string:
String.valueOf(x)
- Java convert to int:
Integer.parseInt(str)
- TC: $O(n)$
Math
1 | class Solution { |
Remarks:
- Be careful of
int
boundary; check beforex10
: comparerev
andInteger.MAX_VALUE/10
. - TC: $O(\log(x))$