Basic In-Memory Spreadsheet
Updated
Problem statement
Implement the basic storage layer of an in-memory spreadsheet.
Process the operations in order:
["SET", cell, value]stores the stringvalueincell, replacing any prior value.["GET", cell]appends the cell's stored value to the result, or the empty string if the cell has not been set.
Return the values produced by all GET operations in order.
Function
runSpreadsheet(operations: String[][]) → String[]Examples
Example 1
operations = [["SET","A1","12"],["GET","A1"]]return = ["12"]The lookup returns the value stored in A1.
Example 2
operations = [["GET","B2"],["SET","B2","hello"],["GET","B2"]]return = ["","hello"]An unset cell is blank; after assignment, the stored value is returned.
Example 3
operations = [["SET","C3","first"],["SET","C3","second"],["GET","C3"]]return = ["second"]A later assignment replaces the previous value.
Constraints
1 <= operations.length <= 100000.- Every operation is a valid
SETorGETin the documented form. - Cell identifiers contain one to twenty uppercase letters or digits.
- Stored values have length at most
100and may be empty.
More Google Onsite Interview questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Mutable Record Store with Error ResultsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
- Phone Spam Report CounterPinterest · ONSITE INTERVIEWPinterest interview questions
- Task Row ModificationsNotion · ONSITE INTERVIEWNotion interview questions
- Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One 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
- In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions