https://school.programmers.co.kr/learn/courses/30/lessons/131127?language=cpp#

#include <string>
#include <vector>
#include<algorithm>
#include<iostream>
    /*
슬라이딩윈도우
    */
using namespace std;
int solution(vector<string> want, vector<int> number, vector<string> discount) {
    int answer = 0;

    bool isOk = true;
    for(int y= 0; y <= discount.size() - 10; ++y){
        for(int x = 0; x < want.size() ; ++x){
            //cout<<"discount[y]: "<<y<<endl;
            //cout<<"want[x]: "<<x<<endl;
            int num = count(discount.begin() + y, discount.begin()+y+10,want[x]);
            //std::cout<<"num: "<< num<<endl;
            if(num < number[x]) 
            {
                isOk =false;
                break;
             }
        }
        if(isOk)answer++;
        isOk = true;
    }
    return answer;
}

'PS > 프로그래머스' 카테고리의 다른 글

캐시 lv-2  (0) 2024.08.06
땅따먹기 lv2  (0) 2024.08.01
모음 사전  (0) 2023.08.26
둘만의 암호  (0) 2023.08.25
네트워크(V)  (0) 2023.08.11

+ Recent posts