NumPy allowed · plain Python earns 10 bonus points
Cosine-like similarity scores ranked before context assembly
Implement the inverted index -- the classic sparse-retrieval data structure (used by BM25, Elasticsearch, and hybrid search systems) that every dense vector index is typically paired with in production RAG.
Implement build_inverted_index(documents): for every unique token across all documents, list every document index (deduplicated, ascending) in which it appears.
build_inverted_index(documents: list[list[str]]) -> dict[str, list[int]]