[JAVA 문제 풀이] 268. 숫자 문자열과 영단어

프로그래머스 (81301)
Stupefyee's avatar
May 21, 2025
[JAVA 문제 풀이] 268. 숫자 문자열과 영단어
notion image
notion image
 

내가 작성한 코드

class Solution { public int solution(String s) { String[] nums = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for (int i = 0; i < nums.length; i++) { String num = nums[i]; s = s.replace(num, String.valueOf(i)); } return Integer.parseInt(s); } }
Share article

stupefyee