View Code of Problem 3693

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <stack>
#include <algorithm>
using namespace std;
int main()
{
	int t, n;
	int i, j, k=0;
	cin >> n;
	string s[100];
	string str;
	for (i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	cin >> str;
	sort(s, s + n);
	for (i = 0; i < n; i++)
	{
		while (str.find(s[i]) != -1)
		{
			k++;
			str.erase(str.find(s[i]), s[i].size());
			i = -1;
			break;
		}		
	}
	cout << k << endl;
	return 0;
}

Double click to view unformatted code.


Back to problem 3693