2025-08-21 12:40:49 +0000 UTC

Remove Trailing Zeros From a String

Code

class Solution:
    def removeTrailingZeros(self, num: str) -> str:
        val = int(num)
        while val > 0 and val % 10 == 0:
            val //= 10
        return str(val)