The core of the question is really just bookkeeping.
Start by clarifying the requirements and constraints, then design the data structures and algorithms to support user management and storage limits. Explain how you would integrate the new functionality with the existing file system, ensuring efficient operations and proper error handling. Finally, discuss trade-offs and potential optimizations.
Pro tip: Demonstrate awareness of real-world concerns like concurrency and scalability, and suggest how to handle them (e.g., locking, sharding). Also, mention the importance of clear error messages and logging for debugging.
Ask questions to understand the expected scale, concurrency needs, and whether storage limits are per-user or global. Confirm the exact behavior for edge cases like zero-byte files or duplicate usernames.
Propose structures: a map for users (username -> User object with used storage), and a map for files (filename -> File object with size and owner). Consider how to track total storage per user efficiently.
Outline algorithms for addUser (check duplicate, insert) and addFile (validate user, check file existence, check storage cap, then insert and update user's used storage). Ensure atomicity if needed.
Explain how to extend the existing file system without breaking prefix/suffix search. For example, maintain the same file map and ensure search still works by not altering file keys.
Talk about time/space complexity, potential bottlenecks (e.g., frequent storage checks), and optimizations like caching or lazy deletion. Mention concurrency control if multi-threaded.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.