Benchmark AI / Public workspace

LiveCodeBench / 2819 / remove-trailing-zeros-from-a-string

Problem

Answer published by the source. Consult the official source to check your work against its answer.

contest date

2023-05-28T00:00:00

contest id

weekly-contest-347

difficulty

easy

platform

leetcode

question content

Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.
 
Example 1:

Input: num = "51230100"
Output: "512301"
Explanation: Integer "51230100" has 2 trailing zeros, we remove them and return integer "512301".

Example 2:

Input: num = "123"
Output: "123"
Explanation: Integer "123" has no trailing zeros, we return integer "123".

 
Constraints:

1 <= num.length <= 1000
num consists of only digits.
num doesn't have any leading zeros.

question title

remove-trailing-zeros-from-a-string

starter code

Code

class Solution:
    def removeTrailingZeros(self, num: str) -> str:
        

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import