Problem · Design
Parquet-Like Columnar Format Operations
Learn this problemProblem statement
Commands use WRITE|v0,v1,... or READ|start|end|c0,c1,.... A successful write returns WRITE: followed by column encodings separated by |, with runs written as value*count. A read returns READ: followed by rows separated by ;. A nonrectangular write returns ERROR and changes nothing.
Function
runColumnarFormat(operations: String[]) → String[]Examples
Example 1
operations = ["WRITE|1,5","WRITE|1,7","READ|0|2|1,0"]return = ["WRITE:1*1|5*1","WRITE:1*2|5*1,7*1","READ:5,1;7,1"]Columnar operation sequence 1 covers writes, reads, RLE boundaries, or rectangularity.
Example 2
operations = ["WRITE|3,3","READ|0|1|0"]return = ["WRITE:3*1|3*1","READ:3"]Columnar operation sequence 2 covers writes, reads, RLE boundaries, or rectangularity.
Constraints
1 <= operations.length <= 2000- The first write has at least one column.
- Read ranges satisfy
0 <= start <= end <= rowsWritten. - Read column indices are valid and nonempty.