웅재의 코딩세상
[프로그래머스] 수 조작하기 2 본문
- 풀이
#include <string>
#include <vector>
#include <map>
using namespace std;
map <int,char> mp = {{1, 'w'}, {-1, 's'}, {10, 'd'}, {-10, 'a'}};
string solution(vector<int>num) {
string result="";
for(int i=0; i<num.size()-1; i++){
result += mp[num[i+1]-num[i]];
}
return result;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 배열 만들기 2 (1) | 2024.01.26 |
---|---|
[프로그래머스] 콜라츠 수열 만들기 (1) | 2024.01.26 |
[프로그래머스] 마지막 두 원소 (0) | 2024.01.26 |
[프로그래머스] 할 일 목록 (0) | 2024.01.25 |
[프로그래머스] 문자열 정수의 합 (0) | 2024.01.25 |