[프로그래머스, 181925] 수 조작하기 2 (java)
Problem Solving/Programmers

[프로그래머스, 181925] 수 조작하기 2 (java)

728x90

https://school.programmers.co.kr/learn/courses/30/lessons/181925

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

728x90

메모리: 79.5 MB, 시간: 11.13 ms

사용 알고리즘: 구현

class Solution {
    public String solution(int[] numLog) {
        
        StringBuilder answer = new StringBuilder();
        
        int num;
        for(int i = 1; i < numLog.length; i++) {
            num = numLog[i] - numLog[i - 1];
            
            if(num == 1) answer.append("w");
            else if(num == -1) answer.append("s");
            else if(num == 10) answer.append("d");
            else answer.append("a");
        }
        
        return answer.toString();
    }
}
728x90