文章
81
粉丝
0
获赞
275
访问
10.5k
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
cin>>str;
int n=str.length();
stack<char>st;
for(int i=0;i<n;i++){
if(!st.empty()){
char now = st.top();
if(str[i]==')'&&now=='('||now=='['&&str[i]==']'){
st.pop();
}else st.push(str[i]);
}else{
st.push(str[i]);
}
}
if(st.empty())cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发