Incremental String Qualification with Split and Merge
Updated
Problem statement
An ordered list of nonempty strings, initialParts, represents one logical string partitioned into adjacent parts. You will process a finite sequence of split and merge operations while preserving the order of all characters.
Operations
["SPLIT", i, offset]: replace partiwith its nonempty prefix of lengthoffsetfollowed by its remaining nonempty suffix.["MERGE", i]: replace partsiandi + 1with their concatenation.
After each operation, classify the current partition:
QUALIFIEDif every current part has length at mostmaxPartLength.UNQUALIFIEDotherwise.
Return one classification per operation, in the same order as operations.
Function
classifyParts(initialParts: String[], operations: String[][], maxPartLength: int) → String[]Examples
Example 1
initialParts = ["abcdef"]operations = [["SPLIT","0","3"],["MERGE","0"],["SPLIT","0","2"],["SPLIT","1","2"]]maxPartLength = 3return = ["QUALIFIED","UNQUALIFIED","UNQUALIFIED","QUALIFIED"]Splitting abcdef at offset 3 produces [abc, def], so both parts qualify. Merging restores one length-6 part. The next split produces lengths 2 and 4, and the final split produces three length-2 parts.
Example 2
initialParts = ["ab","cdef"]operations = [["MERGE","0"],["SPLIT","0","4"]]maxPartLength = 4return = ["UNQUALIFIED","QUALIFIED"]The merge creates abcdef, whose length exceeds 4. Splitting it into abcd and ef makes every part short enough.
Example 3
initialParts = ["a","bc","def"]operations = [["MERGE","0"],["MERGE","0"],["SPLIT","0","3"]]maxPartLength = 3return = ["QUALIFIED","UNQUALIFIED","QUALIFIED"]The first merge creates abc, which still qualifies. The second creates one length-6 part, and splitting it at offset 3 restores two qualified parts.
Constraints
1 ≤ initialParts.length ≤ 2000.1 ≤ operations.length ≤ 2000.1 ≤ maxPartLength ≤ 100.- Each initial part contains only lowercase English letters and has length in
[1, 100]. - The total number of characters across all parts is at most
2000and remains constant. - Every operation is either
SPLITorMERGEwith the exact arity shown above. - Every split index and offset are valid for the current partition and produce two nonempty parts.
- Every merge index has a right-adjacent part in the current partition.
More Stripe Phone Screen questions
- 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
- Invoice / Payment ReconciliationPHONE 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
Similar questions at other companies
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Process Refunds with Bounded RetriesMercor · PHONE SCREENMercor interview questions
- E-commerce Notification RouterAmazon · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Validate a Single-Letter Word SequenceReddit · PHONE SCREENReddit interview questions
- Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Elevator Scheduling SimulationOpenAI · PHONE SCREENOpenAI interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
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)
- Stripe SWE Onsite over Two Days: 1 Experience
- Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences