My issue
can anyone help me to find why my code is showing wrong answer after submitting it.
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
string s;
cin>>s;
int i=0;
while(s[i]!=':'){
i++;
}
long long left=0,right=0,ans=0;
for(int k=i;k<n;k++){
if(s[k]==')'){
right++;
}
else if(s[k]=='('){
left++;
}
else if(right>0 && left==0 && s[k]==':'){
ans++;
left=0;
right=0;
}
}
cout<<ans<<endl;
}
return 0;
}
Problem Link: SMILEY Problem - CodeChef