← All questions
HardCoding
Special Binary String
Asked atTSTechMojo Solutions
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Track balance, adding one for 1 and subtracting one for 0.
- 02Split whenever balance returns to zero.
- 03Recursively maximize the interior of each primitive block.
- 04Sort complete blocks descending and concatenate them.
Reference answer
Then expect these follow-ups
Why does descending block order maximize the result?
Tests: greedy proof
How can you reduce substring copying?
Tests: implementation
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question