BitFont - Render a Kerned Pair
Updated
Problem statement
Two selected bitmap glyphs are supplied as leftGlyph and rightGlyph. Each glyph is a rectangular list of binary row strings. A 1 is ink and a 0 is background. Both glyphs have the same height.
Placement rules
Let L and R be the glyph widths. The left glyph starts at column 0. A kerning value k, with 0 <= k <= L, places the right glyph at column L - k. So k = 0 puts the glyphs side by side, and a larger value moves the right glyph closer.
A placement is valid when no output cell receives ink from both glyphs. Background columns and even the glyph bounding boxes may overlap. Evaluate each final placement independently: an invalid smaller value does not rule out a larger valid value. The right glyph may start at column 0, but never at a negative column.
The supplied k is guaranteed to be the largest valid value under these placement rules. Render that placement without recomputing or validating k.
Return the rows using . for background and * for ink. The output height is the common glyph height and its width is max(L, L - k + R). Preserve all leading and trailing background columns; do not crop the canvas.
Function
renderKernedPair(leftGlyph: String[], rightGlyph: String[], k: int) → String[]Examples
Example 1
leftGlyph = ["101"]rightGlyph = ["010"]k = 3return = ["***"]The largest valid final-placement shift is 3. The right origin is 0. The canvas preserves both full glyph extents, and every ink pixel is printed as an asterisk.
Example 2
leftGlyph = ["11","11"]rightGlyph = ["1","1"]k = 0return = ["***","***"]The shift is 0, so the right glyph starts at column 2, next to the left glyph. The left glyph has two ink cells in each row, and the right glyph adds one more. Each of the two rows is three asterisks.
Example 3
leftGlyph = ["0010","0100"]rightGlyph = ["100","001"]k = 4return = ["*.*.",".**."]The shift is 4, so the right glyph starts at column 0 and sits over the left glyph. In the top row the ink is in the first and third cells. In the bottom row it is in the second and third cells. Empty cells stay as dots, and the canvas keeps the full width of four.
Constraints
1 <= leftGlyph.length == rightGlyph.length <= 100.- Every row in
leftGlyphhas the same widthL; every row inrightGlyphhas the same widthR. 1 <= L, R <= 100.- Rows contain only ASCII
0and1. Entirely background rows or glyphs are allowed. 0 <= k <= L, andkis the largest non-colliding final placement.- The returned canvas contains at most
20,000pixels.
More Stripe Onsite Interview questions
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Transaction Rule Expression EvaluatorONSITE INTERVIEW · Seen Oct 2026
- Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
- Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
- Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026
Similar questions at other companies
- Bounded Word Guess SolverAtlassian · ONSITE INTERVIEW
- Retry with an Attempt LimitOracle · ONSITE INTERVIEW
- Extract Error Log ContextFlexTrade · ONSITE INTERVIEW
- Wildcard Character Array MatchGoogle · ONSITE INTERVIEW
- Print Vertical Asterisk BarsMicrosoft · ONSITE INTERVIEW
- Add Two Numbers Given as Digit ArraysCapital One · ONSITE INTERVIEW
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEW
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEW
- Hex Dump FormatterWaymo · ONSITE INTERVIEW