Can anyone explain me whati am doing wrong in the code below:
Problem code : COMPILER
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int t=0;
cin >> t;
while(t--){
stack<char> st;
string s;
cin >> s;
int i=0;
int res = 0;
while(i<s.length()){
if(s[i]=='<'){
st.push(s[i]);
}else if(!st.empty() && s[i]=='>' && st.top()=='<'){
st.pop();
res+=2;
}
i++;
}
cout << res << endl;
}
return 0;
}