← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Stripe coding round for a software engineer role. The problem looked manageable at first but the real pain was in the pixel-perfect output formatting, not the algorithm itself.

Questions Asked (1)

Q1

You're given a bitfont renderer that maps characters to 2D bitmap glyphs and concatenates them into a single horizontal bitmap. Extend it to support multi-line output: wrap at a max pixel width (preferring whitespace breaks), keep glyph rows flush across each line, and handle spacing and padding exactly per a given spec.

Algorithms & Data StructuresData ModelingTechnical Trade-offs
Author's notes

The word-wrap logic wasn't that bad once I thought of it as accumulating glyph widths and checking against the max.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the spec: how whitespace breaks are preferred, how glyph rows are aligned, and how spacing/padding is applied. Then outline a two-phase algorithm: first tokenize the input into words and measure their pixel widths, then greedily pack words into lines respecting the max width and whitespace preference. Finally, discuss how to render each line with consistent row heights and apply spacing/padding exactly as specified.

Pro tip: Mention that you would write unit tests for edge cases like a single word longer than the max width, multiple consecutive spaces, and empty lines—this shows you think about robustness and spec compliance, which Stripe values.

1. Clarify the spec and constraints

Ask about whitespace handling (e.g., collapse multiple spaces, break at spaces vs. hyphens), padding rules (left/right/top/bottom), and whether glyph rows must be flush (aligned to a common baseline or top). Confirm the max width is in pixels, not characters.

2. Design the data model and measurement

Represent each glyph as a 2D bitmap with known width/height. Precompute the pixel width of each character and space. For words, sum character widths plus inter-character spacing (if any). This allows efficient line-breaking decisions.

3. Implement line-breaking algorithm

Tokenize input into words and whitespace. Greedily add words to the current line while the total width (including spaces) ≤ max width. If a word doesn't fit, start a new line. If a single word exceeds max width, either break it at character boundaries or allow overflow—clarify with interviewer.

4. Render lines with consistent row alignment

For each line, determine the maximum glyph height among its characters. Pad shorter glyphs (top or bottom) so all rows are flush. Then concatenate glyph bitmaps horizontally, inserting spaces between words and applying any specified padding.

5. Handle spacing and padding per spec

Apply exact spacing rules: e.g., one space between words, no trailing spaces, and padding around the entire block. Ensure padding is added after line-breaking, not before, to avoid affecting width calculations.

Key Points to Mention

  • Whitespace preference: break at spaces when possible, but handle cases where a word alone exceeds max width (e.g., break mid-word or overflow).
  • Glyph row alignment: ensure all glyphs in a line share the same baseline or top alignment by padding shorter glyphs with empty rows.
  • Spacing rules: distinguish between inter-character spacing within a word and inter-word spacing; apply consistently.
  • Padding: apply padding (left/right/top/bottom) to the final multi-line bitmap, not to individual lines, to maintain uniform margins.
  • Efficiency: precompute character widths and use a greedy algorithm; consider dynamic programming if optimal line-breaking (e.g., minimizing raggedness) is required.
  • Edge cases: empty input, single character, multiple consecutive spaces, and lines that exactly fit the max width.

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