Number of gem elements


#1

Write a program for the below question:

John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lower-case Latin letter from ‘a’ to ‘z’. An element can be present multiple times in a rock. An element is called a gem-element if it occurs at least once in each of the rocks.Given the list of N rocks with their compositions, display the number of gem-elements that exist in those rocks.


#2

#include<bits/stdc++.h>
#include
#include
using namespace std;
int main(){
int hash[26],N,g,y,count=0;
set gems;
for(int i=0;i<26;i++)
hash[i]=0;
cin>>N;
y=N;
while(N–){
cin>>g;
char c;
while(g–){
cin>>c;
if(gems.find©==gems.end()){
hash[c-97]++;
gems.insert©;
}
}
gems.clear();
}
for(int i=0;i<26;i++){
if(hash[i]==y)
count++;
}
cout<<count<<endl;
}
output


#3

© is ( c ). Please correct