Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- sorting
- Binary Tree
- Stack
- SQL
- java
- geometry
- hash table
- two pointers
- Counting
- Method
- 구현
- Math
- 자바
- dynamic programming
- string
- database
- greedy
- Class
- Binary Search
- 코딩테스트
- Matrix
- simulation
- Tree
- array
- bit manipulation
- 파이썬
- Data Structure
- 코테
- Number Theory
- implement
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2710. Remove Trailing Zeros From a String 본문
1. Input
1) String num
2. Output
1) num에서 후행 0을 뺀 결과를 반환
3. Constraint
1) 1 <= num.length <= 1000
2) num은 숫자로만 이루어져 있다.
3) num에 선행 0은 없다.
4. Example
Input: num = "51230100" -> Output: "512301"
Input: num = "123" -> Output: "123"
5. Code
class Solution {
public String removeTrailingZeros(String num) {
int i = num.length()-1;
while(num.charAt(i)=='0') i--;
return num.substring(0,i+1);
}
}
- 100%, 94%
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2717. Semi-Ordered Permutation (0) | 2023.06.30 |
---|---|
[LeetCode/Easy] 2716. Minimize String Length (0) | 2023.06.30 |
[LeetCode/Easy] 2706. Buy Two Chocolates (0) | 2023.06.30 |
[LeetCode/Easy] 2697. Lexicographically Smallest Palindrome (0) | 2023.06.30 |
[프로그래머스/Lv.1] 명예의 전당 (1) (0) | 2023.06.30 |