class Solution {
    public int solution(int order) {
        int answer = 0;
        String orderStr = Integer.toString(order); // 주어진 숫자를 문자열로 변환
        for (int i = 0; i < orderStr.length(); i++) {
            char c = orderStr.charAt(i); // 문자열에서 한 글자씩 추출
            if (c == '3' || c == '6' || c == '9') {
                answer++; // 해당 문자가 3, 6, 9 중 하나이면 answer 증가
            }
        }
        return answer;
    }
}
profile
I'm still hungry.

0개의 댓글