My Solution (StringBuilder)
1 | class Solution { |
Remarks:
- Be careful of
intboundary; usetryandcatchto 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
intboundary; check beforex10: comparerevandInteger.MAX_VALUE/10. - TC: $O(\log(x))$