728x90
반응형
class Solution {
public int solution(String s) {
int answer = 0;
String[] ars = s.split(" ");
String a = "Z";
for(int i=0; i<ars.length; i++){
if(ars[i].equals(a)){
answer -= Integer.parseInt(ars[i-1]);
continue;
}
answer += Integer.parseInt(ars[i]);
}
return answer;
}
}
728x90
반응형
'알고리즘 문제풀이 > Programmers - 자바' 카테고리의 다른 글
프로그래머스 - 잘라서 배열로 저장하기 (0) | 2023.03.17 |
---|---|
프로그래머스 - 영어가 싫어요 (0) | 2023.03.17 |
프로그래머스 - 공 던지기 (0) | 2023.03.17 |
프로그래머스 - 7의 개수 (0) | 2023.03.17 |
프로그래머스 - 숨어있는 숫자의 덧셈 (2) (0) | 2023.03.17 |