FastPrepURL Segment Compression Part 2 — Bounded Minor Parts
Problems/URL Segment Compression Part 2 — Bounded Minor Parts

URL Segment Compression Part 2 — Bounded Minor Parts

Stripe logoStripe● MediumFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: July 26, 2026 — 🌺 I re-audited the original author-written sources and rebuilt this practice version from the available interview reports. It is about a 95% match to the available source. The major/minor separators, base first-count-last compression, per-major cap m, keep-first-m-1-then-merge rule, and worked examples come directly from the author-written report. A major with one minor part remains unchanged relative to Part 1, meaning the minor part is still base-compressed; it is not returned as raw text. FastPrep supplies the standalone signature, input assumptions, constraints, and additional tests.

A path is split into major parts by /. Each major part is split into minor parts by .. Base-compress a word w as its first character, the number of omitted middle characters, and its last character.

For each major part independently:

  • If it has at most m minor parts, base-compress every minor part exactly as in Part 1.
  • If it has more than m minor parts, base-compress the first m-1 parts separately. Concatenate the original characters of all remaining minor parts (drop their dots) and base-compress that concatenated word as the final token.

The merge uses original characters, never already-compressed tokens. Rejoin minor tokens with . and major parts with /.

Practice sequence

  1. Part 1: compress every minor part
  2. Part 2: cap each major at m minor tokens (current)

Function

compressBounded(s: String, m: int) → String

Examples

Example 1

s = "stripe.com/payments/checkout/customer.john.doe"m = 2return = "s4e.c1m/p6s/c6t/c6r.j5e"

customer is compressed separately; john and doe are concatenated to johndoe and compressed as j5e. One-minor majors such as payments still become p6s.

Example 2

s = "www.api.stripe.com/checkout"m = 3return = "w1w.a1i.s7m/c6t"

The first two minor parts stay separately compressed. stripe and com are merged from original text to stripecom, producing s7m. checkout remains c6t.

Constraints

  • m >= 1.
  • The input has no empty major or minor parts.
  • Every minor part has length at least 2.
  • The middle count may contain multiple digits.
  • A one-minor major is base-compressed just as in Part 1.

Source note: The source image shows the shared two-part URL compression prompt and its two worked examples.

More Stripe Onsite Interview questions

  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Transaction Rule Expression EvaluatorONSITE INTERVIEW · Seen Oct 2026
  • Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
  • Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026

Similar questions at other companies

  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
  • Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN
  • Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
  • Parse Nested Message TypesApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions
  • Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Valid Number with ExponentsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW

Interview reports that mention this question

  • 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
  • Stripe AI Coding Interview, Experienced SWE: 6 Experiences
  • Stripe SWE Intern Payout Scheduler Phone Screen: 1 Experience
  • Stripe New Grad SWE Onsite and HM Round: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String compressBounded(String s, int m) {
      // write your code here
    }
}
Checking account…