Problem Link : CFMM (Making a Meal)
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string meal_str = "codechef";
vector < string > sv(n);
for (int i = 0; i < n; i++) {
cin >> sv[i];
}
map < char, int > m;
for (char c: meal_str) {
m.insert({
c,
0
});
}
for (string s: sv) {
for (char c: s) {
for (auto p: m) {
if (p.first == c) {
m[c]++;
}
}
}
}
int meals = INT_MAX;
for (auto mp: m) {
meals = min(meals, mp.second);
}
cout << meals << endl;
}
}
When I run this code, it is passing the sample testcase but fails on a hidden one, what is wrong with my code or my approach?