FastPrepDecompose an HTTP URL into Components
Problems/Decompose an HTTP URL into Components

Decompose an HTTP URL into Components

Stripe logoStripe● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe intern phone screen. The source keeps the goal of breaking an HTTP URL into parts. It does not give the list of parts, the grammar it supports, edge cases or the function signature. Our version is about 48% the same as the reported question.

Parse one valid HTTP or HTTPS URL and return these six components in order:

  1. scheme, without ://;
  2. host;
  3. explicit port, or an empty string when no port is written;
  4. path;
  5. query, without ?;
  6. fragment, without #.

URL subset for this exercise

  • The scheme is exactly http or https.
  • The host is nonempty and contains lowercase English letters, digits, dots, or hyphens.
  • An optional port follows the host as :digits.
  • An optional path begins with /. If it is absent, return /.
  • An optional query begins with ?, and an optional fragment begins with #.
  • The query and fragment may be empty. Delimiter characters do not appear inside their component values.

Function

decomposeHttpUrl(url: String) → String[]

Examples

Example 1

url = "https://api.example.com:8443/v1/payments?limit=10#recent"return = ["https","api.example.com","8443","/v1/payments","limit=10","recent"]

Every optional component is present. The returned query and fragment omit their leading delimiters.

Example 2

url = "http://example.com?debug=#"return = ["http","example.com","","/","debug=",""]

No explicit port or path is written. The query is debug=, and the fragment is present but empty.

Constraints

  • 8 <= url.length <= 2 * 10^5.
  • url follows the URL subset stated above.
  • The explicit port, when present, contains one to five decimal digits.
  • For this exercise, preserve component text exactly as written.

More Stripe Phone Screen questions

  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Dec 2026
  • Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Payout Reserve CalculatorPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Format a Signed Integer with CommasHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Run-Length DecodingApple · PHONE SCREENApple interview questions
  • Trace Pointer Rebinding and Pointee UpdatesArista Networks · PHONE SCREENArista Networks interview questions
  • Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
  • Decode and Store StringsAirbnb · PHONE SCREENAirbnb interview questions
  • Delimiter-Parsing String Iteratoramo · PHONE SCREEN
  • SimpleRDD Word CountDatologyAI · PHONE SCREEN

Interview reports that mention this question

  • Stripe SWE Intern Technical Screen Questions Guide
  • Stripe SWE Intern URL, Transfers and Bikemap: 1 Experience

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
  • Stripe OA: What It Tests (2026)
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] decomposeHttpUrl(String url) {
        // write your code here
    }

}
Checking account…