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
- 문제해결
- BOJ
- COS PRO
- 코딩테스트
- 문제풀이
- SQL
- priorityqueue
- BFS
- 투포인터
- 프로그래머스
- 운동기록
- dfs
- DP
- 자바
- 코테
- 시뮬레이션
- binary search
- Java
- 알고리즘
- 러닝일지
- math
- oracle
- MySQL
- 백준
- 문자열
- SWEA
- 건강
- greedy
- db
- 이분탐색
Archives
- Today
- Total
슈콩
[프로그래머스] 문자열 정렬하기(1) 본문

[소스 코드]
import java.util.*;
class Solution {
public int[] solution(String my_string) {
List<Integer> list = new ArrayList<>();
int n = my_string.length();
for(int i=0;i<n;i++){
if(my_string.charAt(i)>='0' && my_string.charAt(i)<='9'){
list.add(my_string.charAt(i)-'0');
}
}
Collections.sort(list);
int[] answer = new int[list.size()];
int idx = 0;
for(int i : list){
answer[idx++] = i;
}
return answer;
}
}'Algorithms > Programmers' 카테고리의 다른 글
| [프로그래머스] 문자열 정렬하기(2) (0) | 2025.10.12 |
|---|---|
| [프로그래머스] 대문자와 소문자 (0) | 2025.10.12 |
| [프로그래머스] 문자 리스트를 문자열로 변환하기 (0) | 2025.10.12 |
| [프로그래머스] 문자열 곱하기 (0) | 2025.10.12 |
| [프로그래머스] 문자열의 앞의 글자 (0) | 2025.10.12 |