class Solution {
public:
int countPoints(string ri) {
int n=ri.size();
vector<bool> r(10,false);
vector<bool> g(10,false);
vector<bool> b(10,false);
for(int i=1;i<n;i=i+2)
{
if(ri[i-1]=='R')
{
r[ri[i]-'0']=true;
}
else if(ri[i-1]=='G')
{
g[ri[i]-'0']=true;
}
else if(ri[i-1]=='B')
{
b[ri[i]-'0']=true;
}
}
int c=0;
for(int i=0;i<10;i++)
{
if(r[i]==true && g[i]==true && b[i]==true)
{
c++;
}
}
return c;
}
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter