forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path097. Nineteen.cpp
76 lines (74 loc) · 999 Bytes
/
097. Nineteen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <bits/stdc++.h>
#define lli long long int
#define endl "\n"
using namespace std;
int main()
{
string s;
cin>>s;
vector<char> n,I,e,t;
for(int i=0; i<s.length(); i++)
{
if(s[i] == 'n')
n.push_back('n');
if(s[i] == 'i')
I.push_back('i');
if(s[i] == 'e')
e.push_back('e');
if(s[i] == 't')
t.push_back('t');
}
string ans = "nineteen";
if(n.size() == 0)
{
cout<<0;
return 0;
}
n.pop_back();
int count = 0;
while(1)
{
for(int i=1; i<ans.length(); i++)
{
if(ans[i] == 'n')
{
if(n.size() == 0)
{
cout<<count;
return 0;
}
n.pop_back();
}
if(ans[i] == 'i')
{
if(I.size() == 0)
{
cout<<count;
return 0;
}
I.pop_back();
}
if(ans[i] == 'e')
{
if(e.size() == 0)
{
cout<<count;
return 0;
}
e.pop_back();
}
if(ans[i] == 't')
{
if(t.size() == 0)
{
cout<<count;
return 0;
}
t.pop_back();
}
}
count++;
}
return 0;
}