Task Row Modifications
Updated
Problem statement
Each task owns zero or more integer-valued rows. Process these operations:
["ADD", taskId, rowId, value]adds a new row to a task.["DELETE", taskId, rowId]deletes that row.["MOVE", fromTaskId, toTaskId, rowId]removes the row from taskfromTaskIdand inserts the same row ID and value into the destination task.["SUM", taskId]returns the decimal sum of every row currently owned by that task. An empty or unseen task sums to0.
Return the values produced by SUM operations in order.
Function
runTaskRowModifications(operations: String[][]) → String[]Examples
Example 1
operations = [["ADD","t1","r1","4"],["ADD","t1","r2","7"],["SUM","t1"],["MOVE","t1","t2","r2"],["SUM","t1"],["SUM","t2"],["DELETE","t2","r2"],["SUM","t2"]]return = ["11","4","7","0"]Moving r2 transfers its value from t1 to t2. Deleting it then leaves t2 empty.
Constraints
1 <= operations.length <= 20000.- Task and row IDs are non-empty ASCII strings containing no whitespace.
- Values are decimal integers in
[-10^9, 10^9]. - An
ADDrow ID is absent from its task. - A
DELETEorMOVEsource row exists, and a moved row ID is absent from the destination task. - Every task sum fits a signed 64-bit integer.
More Notion interview questions
- Nested Todo ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- 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
- Page Permission InheritancePHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Text Document HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Sliding Window MedianONSITE INTERVIEW · Seen Oct 2025
- JSON Block Tree OperationsONSITE INTERVIEW · Seen Jul 2025
- Block Type with the Most ChildrenPHONE SCREEN · Seen Mar 2026
- Country with the Most EventsPHONE SCREEN · Seen Mar 2026
Similar questions at other companies
- Basic In-Memory SpreadsheetGoogle · ONSITE INTERVIEWGoogle interview questions
- Mutable Record Store with Error ResultsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
- Phone Spam Report CounterPinterest · ONSITE INTERVIEWPinterest interview questions
- Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One interview questions
- File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions