[프로그래머스]수 조작하기 1

박예림·2023년 5월 25일
0

코테

목록 보기
99/132

class Solution {
    public int solution(int n, String control) {
        String[] chars = control.split("");

        for (int i = 0; i < chars.length; i++) {
            switch (chars[i]) {
                case "w" -> n += 1;
                case "s" -> n -= 1;
                case "d" -> n += 10;
                default -> n -= 10;
            }
        }

        return n;
    }
}
profile
응애 나 아기개발자

0개의 댓글