PROBLEM LINK: Contest Page | CodeChef
Problem Code: Contest Page | CodeChef
Practice: Contest Page | CodeChef
Contest : Internal Contest CodeChef Adgitm Coding Competition | CodeChef
Author: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Tester: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Editorialist: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
DIFFICULTY:
Easy
PROBLEM:
Customers of the restaurant wants to meet Chef to thank him for the delicious sweets he made for free on Diwali occasion, but the Chef meets only those who have the secret key present in the string given by the organizers. It’s difficult for the organizers to arrange the seats. Please help them by finding the total number of customers allowed to meet Chef.
NOTE: Key is Case Sensitive.
EXPLANATION:
Match key and add up if it do so.
SOLUTION:
C++:
#include <bits/stdc++.h>
using namespace std;
int solve(string key,int N,vector cards){
int count=0;
int ks=key.size();
for(int i=0;i<N;i++){
// Base Condition
if(cards[i].size()<ks) continue;
if (cards[i].find(key) != std::string::npos) {
count++;
}
}
return count;
}
int main(){
string key;
cin>>key;
int N;
cin>>N;
vector cards;
for (int i = 0; i < N; i++){
string temp;
cin>>temp;
cards.push_back(temp);
}
cout<<solve(key,N,cards);
}