Minimum Binary String Length After Pair Removals
Problem statement
Given a binary string s, you may repeatedly remove any adjacent pair equal to 01 or 10.
Return the minimum possible length of the remaining string.
Function
minimumRemainingLength(s: String) → intExamples
Example 1
s = "0101"return = 0Remove the first 01, then remove the remaining 01.
Example 2
s = "11100"return = 1Two opposite-bit pairs can be removed, leaving one 1.
Constraints
0 <= s.length <= 100000.- Every character of
sis0or1.