← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Stripe coding round with a string compression problem that had two distinct parts. The problem itself was well-defined but the merging logic in part two had enough edge cases to keep things interesting for a while.

Questions Asked (1)

Q1

Given a string of major parts separated by '/' and minor parts separated by '.', compress each minor part into a format showing the first character, the length, and the last character. Parts shorter than 3 characters stay unchanged. Then, given an integer m, reduce each major part to at most m minor parts by repeatedly merging consecutive compressed parts, where merging two parts adds their lengths plus 1 for the dropped delimiter. Write test cases and discuss edge cases.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The first part clicked pretty fast, just iterate and check length.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the compression rules and merging semantics with examples, then outline a two-phase algorithm: compress each minor part, then greedily merge adjacent parts until each major part has at most m parts. Finally, design test cases covering normal, boundary, and edge conditions, and discuss trade-offs like greedy vs. optimal merging.

Pro tip: Mention that the greedy left-to-right merging is optimal for minimizing the number of parts, but if the goal is to minimize total length, a different strategy might be needed—showing you consider multiple interpretations.

1. Clarify requirements and edge cases

Ask questions to confirm compression rules (e.g., what if length is exactly 3? what about empty parts?) and merging behavior (e.g., does merging preserve order? can we merge non-adjacent parts?).

2. Design compression algorithm

For each minor part, if length < 3, keep as is; else replace with first char + length + last char. Handle empty strings and single-character parts appropriately.

3. Design merging algorithm

For each major part, while the number of minor parts > m, merge adjacent parts by concatenating their compressed forms and adding 1 to the total length (for the dropped delimiter). Use a greedy left-to-right approach.

4. Write test cases

Cover: normal cases (e.g., 'abc.def/ghi.jkl'), parts shorter than 3, exactly 3, empty parts, m=0, m larger than number of parts, and multiple major parts.

5. Discuss edge cases and trade-offs

Address empty input, consecutive delimiters, merging when m is very small, and whether greedy merging is always optimal. Mention time/space complexity.

Key Points to Mention

  • Compression rule: first character, length, last character for parts with length >= 3; otherwise unchanged.
  • Merging rule: merging two parts adds their lengths plus 1 for the dropped delimiter.
  • Greedy left-to-right merging minimizes the number of parts but may not minimize total length.
  • Edge cases: empty string, empty parts (e.g., 'a..b'), m=0, m >= number of parts, parts of length 1 or 2.
  • Test cases should include multiple major parts and varying m values.
  • Time complexity: O(n) for compression and O(k * m) for merging, where k is total minor parts.

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