Mutable Table Aggregations
Updated
Problem statement
Maintain integer-valued rows across independent tables. Process these operations:
["ADD", tableId, rowId, value]inserts a new row.["UPDATE", tableId, rowId, value]replaces an existing row's value.["DELETE", tableId, rowId]removes an existing row.["QUERY", tableId]returnscount|sum|average|maxfor that table.
Format a non-empty table's average with exactly two digits after the decimal point. For an empty table, return 0|0|0.00|NULL. Return the values produced by QUERY operations in order.
Function
runTableAggregations(operations: String[][]) → String[]Examples
Example 1
operations = [["ADD","docs","r1","10"],["ADD","docs","r2","20"],["QUERY","docs"],["UPDATE","docs","r1","40"],["QUERY","docs"],["DELETE","docs","r2"],["QUERY","docs"]]return = ["2|30|15.00|20","2|60|30.00|40","1|40|40.00|40"]The first query aggregates two rows. Updating r1 changes sum, average, and maximum; deleting r2 leaves one row.
Constraints
1 <= operations.length <= 20000.- Table and row IDs are non-empty ASCII strings containing neither
|nor whitespace. - Values are decimal integers in
[-10^9, 10^9]. - An
ADDrow ID is absent from that table; anUPDATEorDELETErow ID is present. - Every table contains at most
10000rows, and every sum fits a signed 64-bit integer.
More Notion interview questions
- Nested Todo ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 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
- 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
- Mutable Points in a Hash Set and a ListMillennium · PHONE SCREENMillennium interview questions
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- File Storage ServiceCresta · PHONE SCREENCresta interview questions
- Hash Map with Separate ChainingApplied Intuition · ONSITE INTERVIEWApplied Intuition interview questions
- Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions