-Code
import java.util.List;
class Solution {
public int solution(String s) {
List<String> numStrings = List.of(
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"
);
for (int i = 0; i < 10; i++) {
String now = numStrings.get(i);
if (s.contains(now)) {
System.out.println(now);
s = s.replaceAll(now, String.valueOf(i));
}
}
return Integer.parseInt(s);
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 문자열 내 마음대로 정렬하기 (0) | 2025.02.26 |
---|---|
[프로그래머스/Java] 푸드 파이트 대회 (0) | 2025.02.26 |
[프로그래머스/Java] 두 개 뽑아서 더하기 (0) | 2025.02.25 |
[프로그래머스/Java] 가장 가까운 같은 글자 (0) | 2025.02.25 |
[프로그래머스/Java] 시저 암호 (0) | 2025.02.25 |