This continues the bitmap-font renderer. To save space, a font may store each glyph row Run-Length-Encoded (RLE). Decode the encoded rows back into full 0/1 strings.
Each encoded row is a sequence of run-length characters. The runs alternate pixel state and always start with off (0): the first run is off, the next on, the next off, and so on. Each run-length character maps to a count:
- digits
0-9mean lengths0through9; - letters
a-zmean lengths10through35(soa= 10,b= 11, ...,z= 35).
For each run character, emit that many copies of the current pixel value, then flip the state for the next run. A run of length 0 emits no pixels but still flips the state — do not special-case zero by skipping the flip, or every later run in that row inverts. All decoded rows end up the same width.
Examples
01 · Example 1
encodedRows = ["532", "19"] return = ["0000011100", "0111111111"]
Row '532': 5 off (00000), 3 on (111), 2 off (00) gives 0000011100. Row '19': 1 off (0), 9 on (111111111) gives 0111111111. Both rows are width 10.
02 · Example 2
encodedRows = ["05", "a0"] return = ["11111", "0000000000"]
Row '05': the first run length is 0 (off) which emits nothing but still flips to on, then 5 on gives 11111. Row 'a0': a = 10 off gives ten 0s, then a 0-length on run emits nothing. This exercises the zero-length-run flip trap.
03 · Example 3
encodedRows = ["3b"] return = ["00011111111111"]
Row '3b': 3 off (000), then b = 11 on (11111111111) gives 00011111111111, a width of 14.
Constraints
- Each encoded row is a string of run-length characters in
0-9ora-z. - Runs alternate state starting from off (
0): off, on, off, on, ... 0-9map to lengths0-9;a-zmap to lengths10-35.- A length-
0run emits nothing but still flips the state. - All decoded rows have the same width.
More Stripe problems
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen Jun 2026
- Record Linkage Part 3 - Full Connected ComponentPHONE SCREEN · Seen Jun 2026
- Shipping Cost Calculator Part 3 - Mixed Fixed/Incremental TiersONSITE INTERVIEW · Seen Jun 2026
- Transaction Fee Calculator - Per-Merchant Volume DiscountPHONE SCREEN · Seen Jun 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 2 - Render a WordONSITE INTERVIEW · Seen Jun 2026
- Factory Cost - Min-Cost Path Skipping One StagePHONE SCREEN · Seen Jun 2026
- HTTP Accept-Language with Quality Scores (q-factors)ONSITE INTERVIEW · Seen Jun 2026
public String[] decodeRle(String[] encodedRows) {
// write your code here
}encodedRows["532", "19"]
expected["0000011100", "0111111111"]
sign in to submit