DCP-205: Balance String Back to All Problems

Medium Divide and Conquer > Greedy


A binary string is balance string if,<br> 1. Number of 1's and 0's are same.<br> 2. For each prefix number of 1's should be greater or equal than number of 0's.<br> Example: 1100, 1010, 10110100 are balance string. 1001, 10101 are not balance string. Given a string binary S. Needs to find the max length of sub string S which is Balance String. Input: ------ Input starts with an integer T, denoting the number of test cases. Each case contains a binary string S. Output: ------- For each test case, output one line containing "Case x: “, where x is the test case number starting from 1, followed by the expected answer.See the sample I/O. 1 <= T <= 100<br> 1 <= |S| <= 10^5 Sample Input ------------ 2 10110100 100101010 Sample Output ------------- Case 1: 8 Case 2: 6


Problem Setter:

MD Musfiqur Rahman Sanim

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.50
C++ 1.50
C++14 1.50
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

33/243

Solve/Submission

Ranking

# User Language Timing
01 sahedsohel Cpp14 0.11s
02 feodorv C 0.14s
03 MazedRupok Cpp14 0.31s
04 Robbinb1993 Cpp 0.50s
05 rayhan50001 Cpp 0.54s
06 mh755628 Cpp 0.76s
07 alhelal_cse Cpp14 0.77s
08 murad_al_wajed Cpp 0.77s
09 seyedssz Cpp14 0.79s
10 Double_O Cpp14 0.80s
11 chowdhury Cpp14 0.80s
12 saurabh3240 Cpp14 0.81s
13 tariqiitju Cpp 1.22s
14 fsshakkhor Cpp14 1.27s
15 Morass Cpp14 1.36s
16 sayedgkm Cpp14 1.44s
17 sangshaptac Cpp14 1.45s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support