3900. Longest Balanced Substring After One Swap
You are given a binary string s consisting only of characters '0' and '1'. A string is balanced if it contains an equal number of '0's and '1's. You can perform at most one swap between any two characters in s. Then, you select a balanced substring from s. Return an integer representing the maximum length of the balanced substring you can select. Example 1: Input: s = "100001" Output: 4 E
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start