https://leetcode.com/problems/remove-trailing-zeros-from-a-string/description/
Remove Trailing Zeros From a String - LeetCode
Can you solve this real interview question? Remove Trailing Zeros From a String - 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" Explan
leetcode.com
1
2
3
|
class Solution:
def removeTrailingZeros(self, num: str) -> str:
return(str(int(num[::-1]))[::-1])
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2595. Number of Even and Odd Bits (0) | 2023.06.27 |
---|---|
leetcode 2716. Minimize String Length (0) | 2023.06.27 |
leetcode 2656. Maximum Sum With Exactly K Elements (0) | 2023.06.26 |
leetcode 35. Search Insert Position (0) | 2023.06.26 |
leetcode 172. Factorial Trailing Zeroes (0) | 2023.06.26 |
댓글