Bob and his strict mom

All submissions for this problem are available.
Bob's mom is strict. She wants Bob to study for the upcoming university entrance exam. Bob has only $N$ days left to study. So she asks Bob to make a schedule. Bob being the obedient son he is, comes up with a schedule quickly. But his mother isn't satisfied with the schedule. According to her, at the end of the $i^{th}$ day $(1 \leq i \leq N)$, the number of days on which Bob has studied till now should be greater than or equal to the number of days on which Bob hasn't studied. So she asks Bob to make changes to the schedule, Bob being the lazy kid he is, wants to make the minimum number of changes. One change is when Bob changes exactly one studying day to a nonstudying day or viceversa. ###Input:  First line will contain $T$, number of testcases. Then the testcases follow.  The first line of each testcase contains a single integer $N$.  The second line of each testcase contains a string $S$. The character at each index $i$ $(1 \leq i \leq N)$ is either $0$ or $1$. If $S[i]$ is 0, it indicates that Bob doesn't study on the $i^{th}$ day and if $S[i]$ is 1, it indicates that he does. ###Output: For each testcase, output in a single line, the minimum number of changes Bob needs to make to the schedule. ###Constraints  $1 \leq T \leq 100$  $1 \leq N \leq 10^3$ ###Sample Input: 1 5 10001 ###Sample Output: 1 ###EXPLANATION: Bob needs to make only $1$ change. He can change either $2^{nd}$ or $3^{rd}$ day from a nonstudying day to a studying day.Author:  enigma27 
Tags  enigma27 
Date Added:  7032019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions