문제
- str2가 "aabbc"이고 str1가 "abc"이면 1 반환
- 그 외는 2 반환
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int rst(string str1, string str2) {
string tmp;
for (int i = 0; i < str1.size(); i++) {
if (find(str2.begin(), str2.end(), str1[i]) != str2.end()) tmp += str1[i];
}
if (tmp == str1) return 1;
return 0;
}
728x90
'c++ 기초' 카테고리의 다른 글
string(k, str[i][j]) (0) | 2025.02.19 |
---|---|
2차 벡터 초기화 (0) | 2025.02.18 |
erase (0) | 2025.02.13 |
범위 기반 for문 (0) | 2025.02.12 |
pair (0) | 2025.02.11 |