193. Remove Trailing Zeros from String

EasyStringString

Given a positive integer represented as a string num, return num with the trailing zeros removed.

The result should not have leading zeros (the input is guaranteed to not have leading zeros).

Input: A string num representing a positive integer (no leading zeros).

Output: The string with all trailing zeros removed.

Examples

Example 1
Input: 51230100
Output: 512301
Explanation: Remove the two trailing zeros.
Example 2
Input: 123
Output: 123
Explanation: No trailing zeros.
Example 3
Input: 1000
Output: 1
Explanation: Three trailing zeros removed.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →