Error
|
|
---|---|
@Ibrahim Nash | 6381 |
@blackshadows | 6329 |
@mb1973 | 5388 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@1905439 | 553 |
@terabaap123 | 508 |
@smitadiwedi1991 | 279 |
@DevanandJayakumar | 250 |
@atishagusain | 244 |
@gupta_10 | 226 |
@nipun edara | 224 |
@shubhamkhullar7 | 224 |
@sharmachandan487 | 204 |
@balunagar | 204 |
@arshjit_singh7 | 190 |
Complete Leaderboard |
Given binary string str of size N the task is to check if the given string is valid or not. A string is called valid if the number of 0's equals the number of 1's and at any moment starting from the left of the string number 0's must be greater than or equals to the number of 1's.
Input:
1. The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
2. The first line of each test case contains a single integer N.
3. The next line contains a binary string without spaces.
Output: For each test case, print "yes" if string is valid. Otherwise, print "no" (without quotes)
Constraints:
1. 1 <= T <= 100
2. 1 <= N <= 104
3. '0' <= str[i] <= '1'
Example:
Input:
2
4
0011
3
001
Output:
yes
no
Explanation:
Test Case 1: String has an equal number of ones and zeros and at each index(starting from left) the number of occurrences of 0's is greater than or equals to the number of occurrences 1's.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes