Minimum Binary String Length After Pair Removals
Updated
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.
More Pinecone Online Assessment questions
Similar questions at other companies
- Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
- Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
- Prepare NotificationMicrosoft · OAMicrosoft interview questions
- Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
- Largest Number With Even Digit FrequenciesDRW · OADRW interview questions
- Minimum Replacements for Unequal Adjacent CharactersIBM · OAIBM interview questions
- Crop Text at a Whole-Word BoundaryAmerican Express · OAAmerican Express interview questions
- Minimum Flips for Even Binary RunsJP Morgan Chase · OAJP Morgan Chase interview questions
- Missing WordsVanguard · OAVanguard interview questions
- Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions