you are given a binary string (only 0's and 1's) s of length n.
you want to convert s into an empty string by performing the following operation the least number of times.
- In one Operation, you can remove an alternating subsequence from s without changing the order of the remaining characters.
your task is to determine the minimum number of operations required to convert s into an empty string.
Note:
An alternating subsequence of a string s is defined as follows
- Any subsequence of length 1
- if length greater than 1, and no two consecutive elements being equal. For Example, '0101', '101', '0' are alternating sequences, while '100' and '01011' are not.
Constraints:
1 <= T <= 10
1 <= n <= 10^6
Sample Input:
1
10
0100100111
Sample Output:
3
Explanation:
remove subsequence "010101" from "0100100111" to make it "0011"
remove subsequence "01" from "0011" to make it "01"
finally, remove subsequence "01" from "01" to make it "" (empty binary string)