1 2 3 4 5 6 7 8 9
| class Solution { public String removeTrailingZeros(String num) { int endIndex = num.length() - 1; while (endIndex >= 0 && num.charAt(endIndex) == '0') { endIndex--; } return num.substring(0, endIndex + 1); } }
|
Reference
2710. Remove Trailing Zeros From a String