View Code of Problem 3913

#include<stdio.h>
#include<string.h>

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int i,j=0;
		char s[100000];
		scanf("%s",&s);
		for(i=0;i<strlen(s);i++){
			if(s[i]=='('){
				j++;
			}
			else if(s[i]==')'){
				j--;
				if(j<0){
					break;
				}
			}
		}
		if(j==0) printf("Yes\n");
		else printf("No\n");
	}
}

Double click to view unformatted code.


Back to problem 3913