class Solution {
public int solution(int n, String control) {
int answer = 0;
for(int i=0;i<control.length();i++){
char ch = control.charAt(i);
if(ch=='w'){
n++;
}
if(ch=='s'){
n--;
}
if(ch=='d'){
n+=10;
}
if(ch=='a'){
n-=10;
}
}
answer=n;
return answer;
}
}
'코딩테스트 > lv0' 카테고리의 다른 글
[프로그래머스 코딩테스트] java Lv.0 수열과 구간 쿼리3 (0) | 2024.10.23 |
---|---|
[프로그래머스 코딩테스트] java Lv.0 배열 만들기2 (1) | 2024.10.23 |
[프로그래머스 코딩테스트] java Lv.0 수 조작하기2 (0) | 2024.10.22 |
[프로그래머스 코딩테스트] java Lv.0 이어붙인 수 (1) | 2024.10.17 |
[프로그래머스 코딩테스트] java Lv.0 원소들의 곱과 합 (0) | 2024.10.17 |