FastPrepRepeated Adjacent Pair Deletion
Problems/Repeated Adjacent Pair Deletion

Repeated Adjacent Pair Deletion

Google logoGoogle● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the exact cascade ACCAB -> AAB -> B. We describe the same process with a stack, so the result is always the same. Our version is about 98% the same as the reported question.

Given a string s, repeatedly remove adjacent pairs of equal characters. After a removal, newly adjacent equal characters must also be removed.

Return the unique remaining string, with no adjacent equal pair left to remove. The process is equivalent to applying removals from left to right with a stack.

Function

removeAdjacentPairs(s: String) → String

Examples

Example 1

s = "ACCAB"return = "B"

Remove CC to get AAB, then remove AA to get B.

Example 2

s = "abbaca"return = "ca"

Removing bb creates aa, whose removal leaves ca.

Example 3

s = "abc"return = "abc"

No adjacent pair is equal.

Constraints

  • 0 <= s.length <= 200000.
  • s contains ASCII letters.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Valid ParenthesesQualys · ONSITE INTERVIEWQualys interview questions
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Valid ParenthesesKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Parenthesis Removals and Their IndicesDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Parenthesis Nesting DepthRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String removeAdjacentPairs(String s) {
        // Write your code here.
    }
}
Checking account…