FastPrepRender a Task Tree from CSV Rows
Problems/Render a Task Tree from CSV Rows

Render a Task Tree from CSV Rows

Stripe logoStripe● MediumFULLTIMENEW GRADINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe phone screen. The report keeps the step-by-step CSV task-tree behavior and one input example. It does not give the full row layout, the exact branch marks, what to do with bad input, or the limits. Our version is about 88% the same as the reported question.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question and a similar version appeared again on October 8, 2026, October 13, 2026, November 6, 2026, November 10, 2026, and November 16, 2026! ૮₍ ˃ ⤙ ˂ ₎ა 💜

You are given valid CSV rows that describe tasks and their subtasks. A subtask can have subtasks of its own, so the rows form one or more trees. Draw these trees as text and return the lines.

Each row has one of these two shapes:

  • A root task: timestamp,task,taskId,taskName.
  • A subtask: timestamp,subtask,parentId,taskId,taskName.

The timestamp is extra information and is not part of the output. Task IDs are unique, and a parent's row always comes before the rows of its children. Roots keep their input order, and so do the children of each task.

List the tasks in this order: a task first, then all of its subtasks (and their subtasks), and only then its next sibling. A root line is taskId taskName. Every other line is built like this:

  • Start with two spaces for each ancestor above the task's parent. A child of a root gets no spaces, and a grandchild of a root gets two.
  • Then write |- if the task has a later sibling, or \- if it is its parent's final child.
  • Then write one space, the task ID, one space, and the task name.

Return one string per line.

Function

renderTaskTree(rows: String[]) → String[]

Examples

Example 1

rows = ["01/01/2025,task,T1,cook dinner","01/01/2025,subtask,T1,T2,buy groceries"]return = ["T1 cook dinner","\\- T2 buy groceries"]

T1 is a root. Its only child T2 is also its final child, so the second line uses \-.

Example 2

rows = ["01/01/2025,task,T1,plan launch","01/01/2025,subtask,T1,T2,write brief","01/01/2025,subtask,T1,T3,build demo","01/01/2025,subtask,T3,T4,record video","01/01/2025,task,T5,review metrics"]return = ["T1 plan launch","|- T2 write brief","\\- T3 build demo","  \\- T4 record video","T5 review metrics"]

T2 has a later sibling, T3, so its line uses |-. T3 is the final child of T1, so it uses \-. Its child T4 has one ancestor above its parent, T1, so its line starts with two spaces. T5 is a second root and comes last.

Example 3

rows = ["2025-01-01,task,A,alpha","2025-01-01,task,B,beta","2025-01-01,subtask,B,C,gamma","2025-01-01,subtask,B,D,delta","2025-01-01,subtask,D,E,epsilon"]return = ["A alpha","B beta","|- C gamma","\\- D delta","  \\- E epsilon"]

A and B are roots and keep their input order. Under B, C has a later sibling, so it uses |-. D is the final child of B, so it uses \-. E is the final child of D, one level deeper. It gets two spaces for its ancestor B, then \-.

Constraints

  • 1 <= rows.length <= 200000.
  • Every row is valid ASCII CSV with no quoted fields, in one of the two shapes above.
  • Every taskId is unique, and every parentId names a task that already exists.
  • The rows form one or more trees with no cycles. The nesting depth is at most 200.
  • Task IDs and names are non-empty and contain no comma.

More Stripe Phone Screen questions

  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE 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
  • 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

Similar questions at other companies

  • Match a Descendant Selector in a DOM TreeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • N-Ary Tree Codec OperationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Recover a Tree from Preorder Depth EncodingSuperhuman · PHONE SCREENSuperhuman interview questions
  • Construct Binary Tree S-ExpressionOptiver · OAOptiver interview questions
  • Count Parent Nodes With a Target SumAdobe · OAAdobe interview questions
  • Diagonal Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Render an Org Chart and Find Skip-Level PairsSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Delete Nodes and Return Forest RootsGoogle · ONSITE INTERVIEWGoogle interview questions
  • House Robber IIIOkta · PHONE SCREENOkta interview questions

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
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] renderTaskTree(String[] rows) {
      // write your code here
    }
}
Checking account…