웅재의 코딩세상

[프로그래머스] 크기가 작은 부분 문자열 본문

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

[프로그래머스] 크기가 작은 부분 문자열

웅드 2024. 2. 9. 16:53

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

int solution(string t, string p) {
    int answer = 0;
    for(int i=0; i<t.size()-p.size()+1; i++){
        if(t.substr(i,p.size()) <= p) answer++;
    }
    return answer;
}
반응형