[자바 코테] matches 활용
2021 카카오 채용연계형 인턴십 첫번째 문제 class Solution { public int solution(String s) { String[] number = {"zero","one", "two","three","four", "five","six","seven","eight","nine"}; int Const = 0; while(s.matches("\\d*")==false){ s = s.replaceAll(number[Const],Integer.toString(Const)); Const++; } return Integer.parseInt(s); } } 간단하게 배열을 사용해서 숫자에 맞는 글자 집어 넣기 Const라는 상수 변수를 생성 보면 "String.matches( )" 라는 명령어를 사용했..
2021. 8. 31.