GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 13 May 2022

Binary String Codeforces Solution | Codeforces Problem Solution 2022

C. Binary String
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

You are given a string s consisting of characters 0 and/or 1.

You have to remove several (possibly zero) characters from the beginning of the string, and then several (possibly zero) characters from the end of the string. The string may become empty after the removals. The cost of the removal is the maximum of the following two values:

  • the number of characters 0 left in the string;
  • the number of characters 1 removed from the string.

Solution Click Below:-  CLICK HERE

What is the minimum cost of removal you can achieve?

Input

The first line contains one integer t (1t104) — the number of test cases.


Each test case consists of one line containing the string s (1|s|2105), consisting of characters 0 and/or 1.

The total length of strings s in all test cases does not exceed 2105.

Output

For each test case, print one integer — the minimum cost of removal you can achieve.

Join Now for Solution:- 

No comments:

Post a Comment