View Code of Problem 3913

#include <stdio.h>
#include <string.h> 
#include <math.h>	
int main(void)
{
	int t;
	scanf("%d",&t);
	char a[100000];
	long count,i;
	while(t--){
		scanf("%s",a);
		count=0;
		for(i=0;i<strlen(a);i++){
			if(count<0){
				printf("No\n");
				break;
			}
			if(a[i]=='('){
				count++;
			}else if(a[i]==')'){
				count--;
			}
		}
		if(count==0){
			printf("Yes\n");
		}else if(count>0){
			printf("No\n");
		}
	}
	return 0;
 }

Double click to view unformatted code.


Back to problem 3913