DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Mirror Index

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
L4

Problem

A search index `d` maps each document id to the single term it matched, and serving lookups needs the inverse: each term pointing back to its documents. Return a new dict whose keys are the unique terms and whose values are the sorted document ids that had that term, keyed as JSON so each term is stringified (the term `1` becomes `"1"`).

Summary

Every value remembers who pointed to it.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons