This problem is paper-only - see explanation for the canonical SQL reasoning.
A covering index includes every column the query touches (SELECT, WHERE, ORDER BY, GROUP BY) so the engine can answer from the index alone, skipping the heap / clustered table read. The auto-grader validates which columns must be in the index.
Given a query parsed into { where: string[], orderBy: string[], select: string[] }, return the minimum set of columns needed for a covering index, with this layout:
- WHERE columns first (deduped, original order),
- ORDER BY columns next (deduped against WHERE, original order),
- Remaining SELECT columns last (deduped against the previous two, in input order). These can go in INCLUDE clause for engines that support it (Postgres / SQL Server).
For the auto-grader: implement coveringIndexColumns(parsed) returning the column array.