Print coderinme Hackerearth problem coderinme

Print coderinme

As a beginner to the programming, Sana came to Coderinme platform, to become a better programmer. She solved some problems and felt very confident. Later being a fan of Coderinme, she gave a problem to her friends to solve. They will be given a string containing only lower case characters (a-z), and they need to find that by using the characters of the given string, how many times they can print “Coderinme”(without quotes). As they are new to programming world, please help them.

Input:
The first line will consists of one integer
N
N denoting the length of string.
Next line will contain the string
S
t
r
Str containing only lower case characters.

Output:
Print one integer, denoting the number of times her friends can print “Coderinme” (without quotes).

Constraints:
1

N

10
6
1≤N≤106
Each character of string
S
t
r
Str will be in range
[
a
,
z
]
[a,z]

#include <iostream>
#include <string>
using namespace std;

int main()
{
   long int m,n;
    cin>>n;
    string Str;
    cin>>Str;
    int s[8]={0};
    for(int i=0;i<n;i++)
{
if(Str[i]=='c') s[0]++;
else if(Str[i]=='o') s[1]++;
else if(Str[i]=='d') s[2]++; 
else if(Str[i]=='e') s[3]++;
else if(Str[i]=='i') s[4]++;
else if(Str[i]=='r') s[5]++;
else if(Str[i]=='n') s[6]++;
else if(Str[i]=='m') s[7]++;
}
s[3]/=2;
m=s[0]+s[1]+s[2]+s[3]+s[4]+s[5]+s[6]+s[7];
for(int i=0;i<8;i++)
{
if(s[i]<m) m=s[i];
}
    cout<<m;
    return 0;
}

Print coderinme
Competitive

Hackerearth Archive

A web developer(Front end and Back end), and DBA at csdamu.com. Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me @about.me/s.saifi

Leave a reply:

Your email address will not be published.