Practice Maximize Active Section with Trade I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
In binary string s, 1 marks an active section and 0 an inactive one. You may make at most one trade: first change an entire contiguous run of ones surrounded by zeroes into zeroes, then change a contiguous run of zeroes surrounded by ones into ones. Evaluate the surrounding conditions as if a virtual 1 were added at both ends of s; those virtual positions are never counted. Return the maximum number of ones in the resulting original-length string.
Source: Maximize Active Section with Trade I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "01"
1
# Example 2
s = "0100"
4
# Example 3
s = "1000100"
7
# Example 4
s = "01010"
4
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize Active Section with Trade I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.