https://school.programmers.co.kr/learn/courses/30/lessons/120892
for문을 code만큼 ++하면서 돌림
#include <string>
#include <vector>
using namespace std;
string solution(string cipher, int code) {
string answer = "";
for(int i = code - 1; i < cipher.length(); i += code)
{
answer += cipher[i];
}
return answer;
}
#include <string>
#include <vector>
using namespace std;
string solution(string cipher, int code) {
string answer = "";
for(int i = 0; i<cipher.size(); i++) {
if((i+1)%code == 0) {
answer.push_back(cipher[i]);
}
}
return answer;
}
for문을 i++로 돌리면서 code에 맞는 인덱스마다 추가하는듯? 탐색 횟수가 더 많은 것 같다.