← 返回 coinbase 的题目列表In-Memory DB: Track per-key operation counts and return Top N keys
类型:online_judge
Problem: In-Memory DB Variant — Track per-key operation counts and return Top N keys
You are implementing a simplified in-memory database that stores data as key -> record.
In this variant, every time an operation is performed on a given key, you must increment that key's operation count by 1. You also need to support querying the Top N keys with the highest operation counts.
Required functionality
Maintain an in-memory structure to support the database operations on a key (the exact operation set is defined by the OA statement).
Maintain a counter opCount[key]: increment it by 1 for every operation that targets key.
Implement a query API that returns the Top N keys sorted by operation count in descending order.
Output
For TopN query, output the list of keys ordered by decreasing operation count.
Constraints
N is a positive integer.
The count is associated with the key (not with individual fields inside the record).
Note: The original post does not include the full I/O format, the complete operation list, or tie-breaking rules. Follow the OA prompt for those details.
Example
Input
N/A (depends on OA command format)
Output
N/A