FastPrepIn-Memory SQL with CSV Initialization
Problems/In-Memory SQL with CSV Initialization

In-Memory SQL with CSV Initialization

Microsoft logoMicrosoft● HardFULLTIMEONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Implement a small in-memory table engine that begins with a CSV string and then executes a sequence of SQL-like commands.

The first row of the CSV contains column names. Remaining rows contain data. Fields are comma-separated; quoted fields may contain commas and escaped double quotes.

Support the following commands:

  • SELECT col1,col2,... WHERE col=value: return matching rows with the selected columns joined by commas
  • INSERT value1,value2,...: append one row
  • DELETE WHERE col=value: delete every matching row

Process commands in order and return every output row produced by the SELECT commands.

Function

runInMemorySql(csv: String, commands: String[]) → String[]

Complete the function runInMemorySql in the editor below.

runInMemorySql has the following parameters:

  1. String csv: the initial table contents
  2. String[] commands: the commands to execute in order

Returns String[]: the output rows produced by all SELECT commands, in order.

Examples

Example 1

csv = "name,age,city\nAlice,30,NY\nBob,25,SF"commands = ["SELECT name WHERE city=NY", "INSERT Charlie,22,NY", "SELECT name,age WHERE city=NY"]return = ["Alice", "Alice,30", "Charlie,22"]

The first query matches Alice. After inserting Charlie, the second query returns both NY rows in table order.

Example 2

csv = "name,age\nAlice,30\nBob,25"commands = ["DELETE WHERE name=Alice", "SELECT name,age WHERE age=25"]return = ["Bob,25"]

Deleting Alice leaves only Bob, who matches the final query.

Constraints

  • The total number of rows plus commands can be as large as 10^5.
  • Quoted CSV fields may contain commas and doubled quotes.
  • Only equality filters are required for this problem version.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Layered ASCII Canvas Command ProcessorAsana · ONSITE INTERVIEW
  • Segmented Durable Key-Value StoreOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Payment Ledger with Refunds and Date QueriesStripe · ONSITE INTERVIEWStripe interview questions
  • Parquet-Like Columnar Format OperationsJump Trading · PHONE SCREENJump Trading interview questions
  • LFU CacheAmazon · ONSITE INTERVIEW
  • LFU CacheSnowflake · OA · ONSITE INTERVIEWSnowflake interview questions
  • Schedule Multiple Software TimersGoogle · ONSITE INTERVIEWGoogle interview questions
  • LRU Cache with TTLAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Recover a Function-Call LRU Cache with a Write-Ahead LogAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Progressive Banking Service OperationsValon · ONSITE INTERVIEW

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] runInMemorySql(String csv, String[] commands) {
        // write your code here
    }

}
Checking account…