# 13711 - Valid String >author: Utin ###### tags: `loop` --- ## Brief See the code below ## Solution 0 ```c= #include <stdio.h> int main() { int n; scanf("%d", &n); for(int t = 0; t < n; t++) { char s[100001]; scanf("%s", s); int l = 0, r = 0, i = 0, hoho = 0; while(s[i] != '\0') { if(s[i] == '(') l += 1; else r += 1; if(l < r) { hoho = 1; break; } i++; } if(l != r) hoho = 1; if(hoho == 1) printf("No\n"); else printf("Yes\n"); } } // By Utin ``` ## Reference
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up