cswork / OA打开练习工作台

MicrosoftOA #32

In-Memory SQL with CSV Initialization

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)字符串模拟/实现迭代器设计

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 Description Complete the function runInMemorySql in the editor below. runInMemorySql has the following parameters:
  • String csv: the initial table contents
  • String[] commands: the commands to execute in order Returns String[]: the output rows produced by all SELECT commands, in order.

Constraints

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