Classify virtual-card numbers with configurable length and prefix rules

Quick Overview

Classify virtual-card identifiers under exercise-specific length and prefix rules, with an unknown range supplied as configuration. Preserve leading zeros, detect overlapping rules, and separate card classification from transaction validity.

Classify virtual-card numbers with configurable length and prefix rules

Company: Capital One

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Extend a virtual-card validation method to distinguish VISA and Mastercard under exercise-specific rules. VISA numbers have 16 or 18 digits and begin with `33`. Mastercard numbers have 16 digits and begin with `44` or have a first-four-digit prefix within a supplied inclusive range. The range endpoints are not specified here and must be provided as configuration. The broader case also validates transactions from card and transaction identifiers. Describe how you would separate card classification from those transaction rules when the complete rule table is supplied. ```hint Make missing rules explicit A prefix range that has not been supplied should remain a required input, rather than being replaced by a remembered real-world card-network range. ``` ### Clarifying Questions - What are the inclusive lower and upper endpoints of the Mastercard four-digit range? - Can configured rules overlap, and should overlap be an error or resolved by a stated precedence? - Which transaction-ID fields and conditions determine transaction validity beyond card classification? - Must leading zeros be preserved, and how should malformed identifiers be reported? ### What a Strong Answer Covers - Exact exercise-specific length and prefix conditions - Configuration validation and ambiguous classification - Separation of parsing, network classification, and transaction predicates - Boundary and malformed-input tests ### Follow-up Questions - How would you add another card family without scattering new conditionals through transaction validation? - What should happen to historical identifiers when the rule configuration changes?

Overview: Classify virtual-card identifiers under exercise-specific length and prefix rules, with an unknown range supplied as configuration. Preserve leading zeros, detect overlapping rules, and separate card classification from transaction validity.

Read the full Capital One Software Engineer interview experience this question came from

Capital One logo
Capital One
Nov 22, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Extend a virtual-card validation method to distinguish VISA and Mastercard under exercise-specific rules. VISA numbers have 16 or 18 digits and begin with 33. Mastercard numbers have 16 digits and begin with 44 or have a first-four-digit prefix within a supplied inclusive range. The range endpoints are not specified here and must be provided as configuration.

The broader case also validates transactions from card and transaction identifiers. Describe how you would separate card classification from those transaction rules when the complete rule table is supplied.

Clarifying Questions Guidance

  • What are the inclusive lower and upper endpoints of the Mastercard four-digit range?
  • Can configured rules overlap, and should overlap be an error or resolved by a stated precedence?
  • Which transaction-ID fields and conditions determine transaction validity beyond card classification?
  • Must leading zeros be preserved, and how should malformed identifiers be reported?

What a Strong Answer Covers Guidance

  • Exact exercise-specific length and prefix conditions
  • Configuration validation and ambiguous classification
  • Separation of parsing, network classification, and transaction predicates
  • Boundary and malformed-input tests

Follow-up Questions Guidance

  • How would you add another card family without scattering new conditionals through transaction validation?
  • What should happen to historical identifiers when the rule configuration changes?