FastPrepMinimum Binary String Length After Pair Removals
Problems/Minimum Binary String Length After Pair Removals

Minimum Binary String Length After Pair Removals

Pinecone logoPinecone● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Pinecone online assessment. The report repeats one removable pair where the second, opposite pair is expected. This version removes adjacent 01 or 10 pairs. Our version is about 90% the same as the reported question.

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) → int

Examples

Example 1

s = "0101"return = 0

Remove the first 01, then remove the remaining 01.

Example 2

s = "11100"return = 1

Two opposite-bit pairs can be removed, leaving one 1.

Constraints

  • 0 <= s.length <= 100000.
  • Every character of s is 0 or 1.

More Pinecone Online Assessment questions

  • Binary Tree Right ViewOA · Seen Feb 2024
  • Set Matrix ZeroesOA · Seen Feb 2024
  • Tic-Tac-Toe Board StatusOA · Seen Feb 2024

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
See Pinecone hiring insights
Saved
class Solution {
    public int minimumRemainingLength(String s) {
        // Write your code here.
    }
}
Checking account…