2710. Remove Trailing Zeros From a String Easy

@problem@discussion
#String



1/**
2 * [2710] Remove Trailing Zeros From a String
3 *
4 * Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.
5 *  
6 * <strong class="example">Example 1:
7 * 
8 * Input: num = "51230100"
9 * Output: "512301"
10 * Explanation: Integer "51230100" has 2 trailing zeros, we remove them and return integer "512301".
11 * 
12 * <strong class="example">Example 2:
13 * 
14 * Input: num = "123"
15 * Output: "123"
16 * Explanation: Integer "123" has no trailing zeros, we return integer "123".
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= num.length <= 1000
22 * 	num consists of only digits.
23 * 	num doesn't have any leading zeros.
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/remove-trailing-zeros-from-a-string/
29// discuss: https://leetcode.com/problems/remove-trailing-zeros-from-a-string/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn remove_trailing_zeros(num: String) -> String {
35        String::new()
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_2710() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.