文章
55
粉丝
100
获赞
12
访问
31.1k
#include<stdio.h>
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
stack<char> stk;
string str;
cin>>str;
int len = str.length();
for(int i = 0; i<len; i++){
if(!stk.empty()&&(str[i] == ')' && stk.top() == '(') || (str[i] == ']' && stk.top() == '[')){
stk.pop();
}else{
stk.push(str[i]);
}
}
if(stk.empty()){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
登录后发布评论
暂无评论,来抢沙发