benchmarks.wiki / Public workspace

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

Problem

Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.

question title

remove-trailing-zeros-from-a-string

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.

starter code

Code

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

contest date

2023-05-28T00:00:00

contest id

weekly-contest-347

difficulty

easy

platform

leetcode

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.

See how this is scored Scored by the benchmark’s own harness

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