웅재의 코딩세상

[프로그래머스] 수 조작하기 1 본문

코딩테스트/프로그래머스 - LV 0

[프로그래머스] 수 조작하기 1

웅드 2024. 1. 25. 14:47

 

 

  • 풀이
#include <string>
#include <vector>
#include <map>
using namespace std;

map <char, int> mp = {{'w', 1}, {'s', -1}, {'d', 10}, {'a', -10}};

int solution(int n, string control) {
    
    for(auto c : control){
        n += mp[c];
    }
    
    return n;
}
반응형