Given a binary string of 0s and 1s. Find the maximum difference of number of 0s and number of 1s (number of 0s – number of 1s) in substrings of the string
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
The solution approach for the above problem is like Kadane's algorithm
The algorithm is like below,
curmax will keep track for local maximum difference and max_sofar is basically for final global solution.
The minimum result will be 1 (We will consider '0' as minimum possible substring)
So, if need an explanation for this answer? contact us directly to get an explanation for this answer