← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Apr 2026New York City

Summary

Google SWE onsite coding round in NYC. One problem, string decompression with nested groups, a twist on a classic LC problem with different syntax. Felt manageable once I recognized the pattern but the parsing details were annoying.

Questions Asked (1)

Q1

Given a compressed string where parenthesized groups are followed by a repeat count like {k}, write a function to fully decompress it. Groups can be nested arbitrarily deep.

Algorithms & Data Structures
Author's notes

I recognized it as a variant of the classic decode-string problem pretty quickly, but the syntax difference tripped me up for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a stack to handle nested groups: push the current string and repeat count when encountering '{', and on '}' pop and repeat the top string, appending to the previous. Iterate through the string, building the result incrementally.

Pro tip: Clarify the input format and constraints first (e.g., whether counts are single or multi-digit, if braces are always balanced). Then discuss trade-offs between stack and recursion, and mention time/space complexity.

1. Clarify the problem

Ask about input format, constraints, and edge cases (e.g., nested groups, multi-digit counts, invalid input). Confirm expected output and complexity requirements.

2. Choose data structures

Decide between stack and recursion. A stack is often more straightforward for iterative parsing and avoids recursion depth limits.

3. Design the algorithm

Outline the parsing logic: maintain a stack of (previous string, repeat count). On '{', push current state and reset; on '}', pop and repeat the current string, then append to previous.

4. Handle edge cases

Consider empty groups, zero repeats, multi-digit numbers, and deeply nested structures. Ensure the code handles them gracefully.

5. Analyze complexity

State time and space complexity: O(n * max repeat) or O(total output length) time, O(depth) space for stack.

Key Points to Mention

  • Stack-based parsing for nested structures
  • Handling multi-digit repeat counts
  • Time complexity proportional to output size
  • Space complexity O(depth) for stack
  • Edge cases: empty groups, zero repeats, unbalanced braces
  • Alternative recursive approach and its trade-offs

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.