FastPrepParse and Expand Supported Card Identifiers
Problems/Parse and Expand Supported Card Identifiers

Parse and Expand Supported Card Identifiers

Stripe logoStripe● MediumFULLTIMENEW GRADINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe phone screen. The reports describe parsing with a length prefix, filtering for exact supported cards, and matching on a generic prefix. Our rules make the order of expansion, putting off a later exact match, and repeated prefixes come out the same every time. A separate report adds a list of RIDs, with no rule for output order. Our version is about 88% the same as the reported questions.

An encoded string contains an ordered sequence of card identifiers. Every entry begins with a two-digit decimal length followed by exactly that many identifier characters. A final single 0 terminates the string.

Return the unique supported card identifiers represented by the sequence, preserving the encoded entry order:

  • If an entry exactly equals a supported identifier, return that identifier at this position.
  • Otherwise the entry is a generic prefix. Expand it to supported identifiers with that prefix, using supported order.
  • If a matching supported identifier appears as an exact entry later in the encoded sequence, defer it to that later position instead of emitting it for the earlier generic prefix.
  • Never return the same supported identifier twice.

Earlier stages and a related variant

These exercises are ungraded follow-ups. The function you write is still resolveSupportedCards.

  1. parseCardIdentifiers(String encoded) -> String[]: decode every entry in order. Preserve repeated entries. The final single 0 is a terminator, so "0" decodes to an empty array. For example, "02AA02AA01B0" returns ["AA","AA","B"].
  2. exactSupportedCards(String encoded, String[] supported) -> String[]: return only decoded entries that exactly belong to supported. Preserve their encoded order and repeated occurrences. For the preceding stream and ["AA"], return ["AA","AA"]. This stage performs no generic-prefix expansion.
  3. supportedCardsWithRids(String encoded, String[] supported, String[] supportedRids) -> String[]: decode the stream, then retain each decoded identifier if it is an exact supported identifier or starts with a supplied RID. This is a separate three-input stream-filtering variant; it does not expand a generic entry into identifiers from supported, defer later entries, or remove duplicate occurrences. For "04AA0104BB0204AA0104CC030", supported ["BB02"] and RIDs ["AA"], return ["AA01","BB02","AA01"].

For these follow-ups, assume the same valid two-digit encoding and ASCII identifier alphabet. Support and RID arrays may be empty; their entries are non-empty ASCII identifiers. Use the RID as a prefix, and use the exact-or-prefix rule stated above. Keep stream order and duplicate occurrences.

For resolveSupportedCards, a later exact identifier is deferred after an earlier generic entry. Keep the first emission of an identifier and apply only that later-exact deferral; do not demote repeated broader prefixes.

Function

resolveSupportedCards(encoded: String, supported: String[]) → String[]

Examples

Example 1

encoded = "04432108432100020"supported = ["43210001","43210002","43210003"]return = ["43210001","43210003","43210002"]

The generic prefix 4321 expands in supported order, but 43210002 is deferred because it appears as the next exact entry.

Example 2

encoded = "18DS012345678987654310AI012345670"supported = ["AI01234567","DS0123456789876543"]return = ["DS0123456789876543","AI01234567"]

Both entries are exact supported identifiers, so their encoded order is retained.

Constraints

  • 1 <= supported.length <= 1000; supported identifiers are unique.
  • Each encoded entry length is between 1 and 99.
  • The encoded string is valid and ends with one terminal 0.
  • Generic entries match at least one supported identifier.
  • Identifiers contain ASCII letters and digits only.

More Stripe Phone Screen questions

  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions
  • Chatbot Away-Status RefactorOpenAI · PHONE SCREENOpenAI interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Chemical Formula WeightAgoda · PHONE SCREENAgoda interview questions
  • Count Repeat Customers Across DatesAmazon · PHONE SCREEN
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • JSON Identity VerificationKikoff · PHONE SCREENKikoff interview questions
  • Parse Query StringAirbnb · PHONE SCREENAirbnb interview questions

Interview reports that mention this question

  • Stripe SWE Intern Technical Screen Questions Guide
  • Stripe US SWE Intern Card-String Screen: 1 Experience
  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] resolveSupportedCards(String encoded, String[] supported) {
      // write your code here
    }
}
Checking account…