This question evaluates competency in in-memory data structures, algorithmic complexity, API and system design for storage services, including capacity management, top-K retrievals, deterministic conflict resolution during merges, and snapshot isolation; it is categorized under Coding & Algorithms with strong overlap into storage/system-design concepts. It is commonly asked to assess the ability to balance correctness and efficiency when specifying data structures, operation complexities, and update semantics for practical features like user quotas, merges, backups and restores, therefore testing both practical implementation skills and conceptual system-design understanding.

Implement an in-memory cloud storage service that maps file objects to their metadata. The system should support the following levels of functionality: Level 1: Add a new file, retrieve a file’s metadata, and delete a file. Define clear identifiers (e.g., fileId) and metadata fields (at least name and size). Level 2: Display the K largest files globally; specify the return format and expected time complexities. Aim for efficient updates as files are added/removed. Level 3: Add users with per-user storage capacity limits. Support uploading files under a user while enforcing capacity, and implement merging two users’ storage into one. Define and implement a deterministic conflict policy for duplicate file identifiers or names during merge, and update capacities/usage accordingly. Level 4: Support creating backups (point-in-time snapshots) of a user’s files and restoring a user to a chosen backup. Ensure that later modifications do not mutate earlier backups (snapshot isolation). Provide API design, data structures, and complexity analysis for all operations. Concurrency and real filesystem access are not required.