Your question is Nested Record Query Index. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a list of records where each record is a nested dictionary, implement a function that preprocesses the records and answers equality-based search queries efficiently. Each query is a dictionary mapping dot-separated field paths (such as "user.name" or "meta.region") to required values. Return the list of record IDs that satisfy all query conditions.
def optimize_queries(records, queries):