题解
2023-07-26 13:28:10
发布于:浙江
6阅读
0回复
0点赞
AC代码
#include <bits/stdc++.h>
using namespace std;
const int N=260;
int arr[N],too;
int main() {
	string str;
	cin>>str;
	int n = str.size();
	for(int i=0;i<n;i++){
		if(str[i]=='(')
			arr[++too]=1;
		else if(str[i]==')'){
			too--;
			if(too==-1){
				cout<<"NO";
				return 0;
			}
		}
	}
	if(too==0){
		cout<<"YES";
	}
	else cout<<"NO";
	return 0;
}
这里空空如也

有帮助,赞一个