Question Link—> COMPILER Problem - CodeChef
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
string str;
cin>>str;
// if(str==“–”)
// break;
stackst;
int k=0;
int count_balance=0;
//cout<<str.length();
for(int i =0;i<str.length();i++)
{
if(str[i]==‘<’)
k+=1;
else
k-=1;
if(k<0)
{
count_balance=0;
break;
}
if(k==0)
{
count_balance=i+1;
}
}
while(!st.empty())
{
st.pop();
}
cout<<count_balance<<"\n";
}
}