프로그래머스 155652 둘만의 암호

1 개요[ | ]

프로그래머스 155652 둘만의 암호

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

char next(char ch) {
    if(ch == 'z') return 'a';
    return ch+1;
}

string solution(string s, string skip, int index) {
    for(char& ch: s) {
        for(int i=0; i<index; i++) {
            ch = next(ch);
            while(true) {
                bool skipped = false;
                for(char& ch2: skip) {
                    if(ch2 == ch) skipped = true;
                }
                if(!skipped) break;
                ch = next(ch);
            }
        }
    }
    return s;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}