Reported September 2026
Stripehash table

Build a Task and Subtask Hierarchy

Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Stripe OA. Under 2s to a working solution.
Founder's read

Stripe's September 2026 OA report has a problem that looks like a data-parsing chore and is really a grouping-and-sorting exercise. You get an unordered pile of task and subtask records, and you have to print a clean hierarchy. The input caps at 200 records, so nobody is checking whether you can scale. They're checking whether you read the spec closely. The trick is small, but the format rules are easy to fumble under a clock. If you blank on the ordering or the grouping, StealthCoder runs invisibly during the live OA and gives you a working solution as a safety net.

The problem

You are given an unordered array of task and subtask records.
A task record is [date, "task", taskId, name].
A subtask record is [date, "subtask", subtaskId, parentTaskId, name].
First separate task records from subtask records. Then serialize the hierarchy by ordering tasks by (date, taskId). Emit each task followed immediately by its direct subtasks ordered by (date, subtaskId).
Serialize a task as TASK|taskId|name and a subtask as SUBTASK|subtaskId|name. Return the emitted lines.

Function
buildTaskHierarchy(records: String[][]) → String[]

Examples
Example 1
records = [["2026-01-03","subtask","s2","t1","review"],["2026-01-02","task","t2","ship"],["2026-01-01","task","t1","build"],["2026-01-02","subtask","s1","t1","code"]]
return = ["TASK|t1|build","SUBTASK|s1|code","SUBTASK|s2|review","TASK|t2|ship"]
Task t1 is earlier than t2. Its two subtasks follow it in date order even though every input record is unordered.
Example 2
records = [["2026-02-01","task","b","Beta"],["2026-02-01","task","a","Alpha"]]
return = ["TASK|a|Alpha","TASK|b|Beta"]
Equal task dates break ties by task ID. Tasks with no subtasks still appear.

Constraints
0 <= records.length <= 200.
Every record has one of the two stated shapes and uses the exact lowercase marker task or subtask.
Dates use zero-padded YYYY-MM-DD format.
All task and subtask IDs are unique, and every subtask names an existing task.
IDs and names contain 1 to 50 letters, digits, spaces, hyphens, or underscores and do not contain |.
Only direct task-to-subtask relationships are present.

Reported by candidates. Source: FastPrep

Pattern and pitfall

With at most 200 records, brute force would pass on size, so the real test is correctness. Split records by the marker field. Put tasks in a list and sort by (date, taskId). Build a hash map from parentTaskId to a list of subtasks, then sort each list by (date, subtaskId). Walk the sorted tasks, emit TASK|id|name, then emit each child as SUBTASK|id|name. Dates are zero-padded YYYY-MM-DD, so plain string comparison sorts them correctly and you don't need date parsing. Common pitfalls: subtask records have five fields while task records have four, so the name sits at a different index. Another is sorting subtasks globally and losing the grouping. Tasks with no subtasks must still appear. The empty input returns an empty list. If the index shuffling trips you up mid-assessment, StealthCoder is the hedge that keeps you moving.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Build a Task and Subtask Hierarchy cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Stripe's OA.

Stripe reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Build a Task and Subtask Hierarchy FAQ

How hard is the Stripe task hierarchy problem really?+

Easy to medium. There's no clever algorithm. It's a split, group, sort, and format task. Most failures come from wrong field indexes or sloppy tie-breaking, not from the idea. If you can write a sort with a two-key comparator, you can finish this.

What's the trick to solving it cleanly?+

Group subtasks by parentTaskId in a map, sort each group by (date, subtaskId), then sort tasks by (date, taskId) and emit in one pass. Sorting once per group keeps the output order correct without any nested searching.

Do I need to parse the dates?+

No. Dates are zero-padded YYYY-MM-DD, so lexicographic string comparison matches chronological order. Sort by the tuple of date string then ID string. Parsing dates adds code and bug risk for zero benefit here.

What edge cases should I test before submitting?+

Test empty input, tasks with no subtasks, two tasks sharing a date where the ID breaks the tie, and subtasks arriving before their parent task in the array. Also check that subtask name comes from index 4, not index 3.

How do I prepare for this in 48 hours?+

Practice writing multi-key sorts and group-by-key maps in your language until they're automatic. Then rehearse reading record formats carefully and mapping field indexes. This pattern shows up often in data-formatting OAs, so speed on the boilerplate matters more than new algorithms.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Stripe.

OA at Stripe?
Invisible during screen share
Get it