FastPrepNested Todo List
Problems/Nested Todo List

Nested Todo List

Notion logoNotion● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reports describe an open-ended nested todo-list. It has item creation, a hierarchy, and a done or undone state. We chose the operation and rendering formats, since the reports leave out the interface details.

Our version is about 94% the same as the reported questions.

Process operations against an initially empty nested todo list. Items form an ordered forest.

  • ["ADD", id, parentId, text] adds a pending item. A parentId of - makes it a root; otherwise it becomes the newest child of that parent.
  • ["TOGGLE", id] switches that item between PENDING and DONE. Toggling one item does not change descendants or ancestors.
  • ["GET", id] returns id|parentId|status|text.
  • ["RENDER"] returns every item in preorder. Each line is depth|id|status|text, roots and siblings retain insertion order, and lines are joined by a newline.

Return the values produced by GET and RENDER operations in order.

Function

runNestedTodoList(operations: String[][]) → String[]

Examples

Example 1

operations = [["ADD","1","-","Plan"],["ADD","2","1","Draft"],["ADD","3","1","Review"],["TOGGLE","2"],["GET","2"],["RENDER"]]return = ["2|1|DONE|Draft","0|1|PENDING|Plan\n1|2|DONE|Draft\n1|3|PENDING|Review"]

The two children retain insertion order. Toggling item 2 changes only that item.

Constraints

  • 1 <= operations.length <= 20000.
  • IDs are unique non-empty strings containing neither | nor whitespace.
  • Every non-root parent exists before its child is added.
  • Every GET and TOGGLE references an existing item.
  • Text is non-empty and contains neither | nor a newline.
  • The total number of rendered item lines is at most 200000.

More Notion interview questions

  • Mutable Table AggregationsPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2026
  • Block Type with the Most ChildrenPHONE SCREEN · Seen Mar 2026
  • Country with the Most EventsPHONE SCREEN · Seen Mar 2026
  • Event Type with the Most EventsPHONE SCREEN · Seen Mar 2026
  • Most Popular Active Plan for the Top Event TypePHONE SCREEN · Seen Mar 2026
  • Page Permission InheritancePHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
  • Percentage of Blocks Never EditedPHONE SCREEN · Seen Mar 2026
  • Text Document HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
  • Versioned Document StorePHONE SCREEN · Seen Apr 2025
  • Top Error Types in a Time WindowONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Serialize and Deserialize an N-Ary TreeUber · ONSITE INTERVIEWUber interview questions
  • Workspace File System With Folders and TablesClay · PHONE SCREEN
  • Throne Inheritance Without an Initial KingSnowflake · PHONE SCREENSnowflake interview questions
  • Render a Comment HierarchyAmazon · ONSITE INTERVIEW
  • Nested Recipe Inventory ManagerStackAdapt · PHONE SCREENStackAdapt interview questions
  • Render a Stable Comment HierarchyBobyard · PHONE SCREEN
  • Delete a Filesystem TreeDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions

Interview reports that mention this question

  • Notion Interviews, Level Not Reported: 20 Experiences

Notion interview experiences

  • Notion Experienced SWE Interviews: 7 Experiences
  • Notion SWE New Grad Interviews: 3 Experiences
  • Notion SWE Intern Interviews and Debugging Round: 6 Experiences
  • Notion New Grad SWE Onsite Invitations: 2 Experiences
All Notion interview questionsSee Notion hiring insights
Saved
class Solution {
    public String[] runNestedTodoList(String[][] operations) {
        // Write your code here.
    }
}
Checking account…