FastPrepHTTP Accept-Language Matching (Exact, Prefix, Wildcard)
Problems/HTTP Accept-Language Matching (Exact, Prefix, Wildcard)

HTTP Accept-Language Matching (Exact, Prefix, Wildcard)

Stripe logoStripe● MediumFULLTIMENEW GRADINTERNPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reports support exact-tag matching, generic-language expansion, wildcard matching, preference order and deduplication. The practice matches the available sources at about 95%. One report restricts the wildcard to the final header entry; quality-score follow-ups belong to the separate exercise.

Practice sequence: Exact, prefix, and wildcard matching → Quality scores (q-factors).

You serve localized content by resolving a browser's HTTP Accept-Language header against the languages your server supports. The header lists language tags in order of preference, separated by commas, with optional surrounding spaces.

Given acceptHeader and supportedLanguages, return the supported tags that work for the request in descending client preference order. Apply these source-defined parts as you scan the header left to right:

  1. Part 1 — exact match: a tag such as en-US matches the same supported tag.
  2. Part 2 — generic language: a region-less tag such as en matches supported variants that start with en-.
  3. Part 3 — wildcard: * matches every supported tag not already selected.

When one header entry matches several supported languages, keep their order from supportedLanguages. Never return a supported tag more than once.

Function

parseAcceptLanguage(acceptHeader: String, supportedLanguages: String[]) → String[]

Examples

Example 1

acceptHeader = "fr-FR, fr"supportedLanguages = ["en-US", "fr-CA", "fr-FR"]return = ["fr-FR", "fr-CA"]

fr-FR is an exact match and comes first. Then the generic fr matches the remaining French variant fr-CA (fr-FR is skipped because it is already used). en-US is never requested.

Example 2

acceptHeader = "fr-FR, fr, *"supportedLanguages = ["en-US", "fr-CA", "fr-FR"]return = ["fr-FR", "fr-CA", "en-US"]

fr-FR matches exactly. fr matches fr-CA. The wildcard * then grabs the last unmatched supported tag, en-US.

Example 3

acceptHeader = "en-US, fr-CA, fr-FR"supportedLanguages = ["fr-FR", "en-US"]return = ["en-US", "fr-FR"]

en-US is first in the header and supported. fr-CA is not supported. fr-FR is third in the header and supported. Order follows the header preference.

Constraints

  • acceptHeader is a comma-separated list of tags with optional surrounding spaces.
  • Exact matches use the full tag; a region-less generic tag matches every supported tag starting with generic-.
  • * matches all not-yet-matched supported tags, in supportedLanguages order.
  • Preserve the header's preference order; never output a supported tag twice.
  • Return the matched supported tags as a String[].

More Stripe Phone Screen questions

  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE 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
  • Account Roles With Parent-User InheritancePHONE SCREEN · Seen Nov 2026
  • Merchant Payout Scheduler, Part 3: Hold PeriodsPHONE SCREEN · Seen Nov 2026
  • Merchant Payout Scheduler, Part 1PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Count Repeat Customers Across DatesAmazon · PHONE SCREEN
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions

Interview reports that mention this question

  • Stripe SWE Intern Technical Screen Questions Guide
  • Stripe Toronto SWE Intern Accept-Language Screen: 1 Experience
  • Stripe SWE Intern Accept-Language Screen: 1 Experience
  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] parseAcceptLanguage(String acceptHeader, String[] supportedLanguages) {
      // write your code here
    }
}
Checking account…