Skip to content

Commit 45d44a7

Browse files
authoredMay 18, 2019
Create 44_codechef_making_a_meal.cpp
1 parent 500b080 commit 45d44a7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
 

‎44_codechef_making_a_meal.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// main.cpp
3+
// CODE-CHEF
4+
//
5+
// Created by Prince Kumar on 18/05/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// ------ ** Making a Meal ** -------- //
9+
10+
#include<iostream>
11+
#include <vector>
12+
#include <algorithm>
13+
using namespace std;
14+
int main()
15+
{
16+
int T;cin>>T;
17+
while(T--)
18+
{
19+
int n;cin>>n;
20+
int bowl[26]={0};
21+
for(int i=0;i<n;i++)
22+
{
23+
string s;cin>>s;
24+
for(int j=0;j<s.size();j++)
25+
{
26+
int x = s[j] - 97;
27+
bowl[x]++;
28+
}
29+
}
30+
// we get all letters
31+
32+
vector<int> v;
33+
v.push_back(bowl[2]/2); // for 'c'
34+
v.push_back(bowl[3]/1); // for 'd'
35+
v.push_back(bowl[4]/2); // for 'e'
36+
v.push_back(bowl[5]/1); // for 'f'
37+
v.push_back(bowl[7]/1); // for 'h'
38+
v.push_back(bowl[14]/1); // for 'o'
39+
40+
sort(v.begin(),v.end());
41+
cout<<v[0]<<endl;
42+
43+
}
44+
}
45+
46+
47+

0 commit comments

Comments
 (0)
Please sign in to comment.