Execute In-Memory SQL Queries
Updated
Problem statement
Execute a finite ordered batch against an in-memory database service. The five input arrays have equal length. Return one result per operation.
CREATE_DBcreates a database.CREATE_TABLEcreates a table in an existing database.INSERTstoresvalues[i]at a new integer row ID.READreturns the current value for an existing row.UPDATEreplaces the value of an existing row.DELETEremoves an existing row.
A successful write returns OK. A missing parent, missing row, or duplicate create/insert returns ERROR and changes no state. Fields unused by an operation may contain the empty value for their type.
Function
executeStorageOperations(operations: String[], databases: String[], tables: String[], ids: int[], values: String[]) → String[]Examples
Example 1
operations = ["CREATE_DB","CREATE_TABLE","INSERT","READ","UPDATE","READ","DELETE","READ"]databases = ["sales","sales","sales","sales","sales","sales","sales","sales"]tables = ["","orders","orders","orders","orders","orders","orders","orders"]ids = [0,0,7,7,7,7,7,7]values = ["","","new","","paid","","",""]return = ["OK","OK","OK","new","OK","paid","OK","ERROR"]The update changes the stored row and deletion removes it.
Example 2
operations = ["CREATE_TABLE","CREATE_DB","CREATE_DB","CREATE_TABLE","INSERT","INSERT"]databases = ["x","x","x","x","x","x"]tables = ["t","","","t","t","t"]ids = [0,0,0,0,1,1]values = ["","","","","a","b"]return = ["ERROR","OK","ERROR","OK","OK","ERROR"]Parents must exist and duplicate creates or inserts fail.
Example 3
operations = []databases = []tables = []ids = []values = []return = []An empty batch has no results.
Constraints
0 <= operations.length <= 100000and all five arrays have that length.- Every operation is one of the six documented uppercase strings.
- Database and table names used by their operations are nonempty and at most 100 characters.
- Row IDs are nonnegative, and stored values have at most 1000 characters.
More Retool interview questions
- Maximum Profit with Exactly One Stock TransactionPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Order Sources by Their DependenciesPHONE SCREEN · Seen Oct 2026
- Maximum Profit with Exactly Two Stock TransactionsPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Next Consistent Wordle GuessPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2024
- Wordle FeedbackPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2024
- Wordle Guess LoopPHONE SCREEN · Seen Jun 2024
- Markov Transition Counts and ProbabilitiesONSITE INTERVIEW · Seen Mar 2026
Similar questions at other companies
- 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
- In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey 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