← 返回 instacart 的题目列表Filter a Long Table with Two Dropdowns and a Text Search Box
类型:online_judge
Problem: Add Filters to a Long Frontend Table
An existing page renders a very long table of records. Product asks you to add:
A first dropdown filtering by department;
A second dropdown filtering by status;
A text input searching name by case-insensitive substring match.
Implement the core filtering logic. The filtered result must preserve the original table order.
Input Format
n
id|name|department|status
... n rows
department_filter
status_filter
query
department_filter is a department name, or ALL for no department filter;
status_filter is a status value, or ALL for no status filter;
query is an empty string or arbitrary text; if empty, do not filter by name;
name search is case-insensitive.
Output Format
Print the id of every matching record, one per line. If there is no match, print:
EMPTY
Constraints
0 <= n <= 200000
Each row length is at most 500
The filtering should run in linear time.
Example
Input
5
1|Organic Milk|Dairy|active
2|Whole Wheat Bread|Bakery|active
3|Greek Yogurt|Dairy|archived
4|Almond Milk|Dairy|active
5|Apple|Produce|active
Dairy
active
milk
Output
1
4