FastPrepNested Todo List
Problems/Nested Todo List

Nested Todo List

Notion logoNotion● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: Reports describe an open-ended nested todo-list implementation with item creation, hierarchy, and done/undone state. The judged core task matches the visible reports at about 94%; explicit operation and rendering formats resolve omitted interface details.

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 problems

  • Top Error Types in a Time WindowONSITE INTERVIEW · Seen Jun 2026
  • DAG Downstream NodesONSITE INTERVIEW · Seen Apr 2026
  • Mutable Table AggregationsPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2026
All Notion interview questionsSee Notion hiring insights
Saved
class Solution {
    public String[] runNestedTodoList(String[][] operations) {
        // Write your code here.
    }
}
Checking account…