-Code
class Solution {
public String solution(int[] numLog) {
String answer = "";
for (int i = 1; i < numLog.length; i++) {
int dif = numLog[i] - numLog[i - 1];
if (dif == 1) {
answer += "w";
} else if (dif == -1) {
answer += "s";
} else if (dif == 10) {
answer += "d";
} else {
answer += "a";
}
}
return answer;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 수열과 구간 쿼리 3 (0) | 2025.02.08 |
---|---|
[프로그래머스/Java] 수열과 구간 쿼리 2 (0) | 2025.02.08 |
[프로그래머스/Java] 수 조작하기 1 (0) | 2025.02.08 |
[프로그래머스/Java] 마지막 두 원소 (0) | 2025.02.08 |
[프로그래머스/Java] 원하는 문자열 찾기 (0) | 2025.02.07 |