← Questions

Decode and expand supported card identifiers

0
StripeCodingLast asked Jan 2025

A payment card reports the applications it supports as one encoded string: each entry is a two-digit length followed by that many characters, and a single 0 ends the string. A terminal has its own ordered list of supported identifiers.

  1. Decode the string into its entries, in order.
  2. Keep only the entries that exactly match an identifier the terminal supports.
  3. Treat an entry that is not an exact match as a prefix and expand it to every supported identifier that starts with it, in the terminal's order. Never output an identifier twice, and if an identifier appears later as an exact entry, place it there instead of under the earlier prefix.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding