Available question text
For each query substring (augmented with a '1' at both ends), compute the maximum number of '1's obtainable by doing at most one "trade" that replaces an internal run of 1s (surrounded by 0s) with 0s and then flips an internal run of 0s (surrounded by 1s) to 1s. The core challenge is to pick runs to maximize net gain in ones for each query — solvable by run-length encoding plus range-query preprocessing (e.g., segment trees or sparse tables) to evaluate best trade quickly.
Related questions
Continue with questions that share topics or the same question type.
- Maximize Active Section with Trade I
Coding
- Active Businesses
Coding
- Active Users
Coding
- Aggregate Recent Message Events And Active Chats
Coding · Data Structure Design
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3501. Maximize Active Section with Trade II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source