View Code of Problem 3913

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

Double click to view unformatted code.


Back to problem 3913