In-memory table filtering
A reporting query runs over a small table held in memory. columns names the table's columns in order, and the first of them is the row id, which is never missing. Each entry of rows is one row, its values joined by vertical bars in column order, and the text NULL standing in for a value means that value is missing. Each entry of filters carries three fields joined by bars: a column name, an op, then a value. op is eq, ne or missing. eq keeps a row when that column reads exactly the value, ne keeps it when it reads something else, and missing keeps it when the value is absent, so its value field is ignored and may be empty. A comparison against a missing value is neither true nor false, so eq and ne both drop that row. A row comes back only when every filter keeps it. Values hold no bars and every filter names a real column. Return the ids of the rows that come back, in table order.
rows_passing_filters(columns: list[str], rows: list[str], filters: list[str]) → list[str][["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|ne|us"]]out["c1","c4"][["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|missing|"]]out["c2"][["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|eq|NULL"]]out[]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|ne|us"]]["c1","c4"]not run yetsample[["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|missing|"]]["c2"]not run yetsample[["id","region","tier"],["c1|eu|gold","c2|NULL|gold","c3|us|NULL","c4||gold"],["region|eq|NULL"]][]not run yetsample