Design and implement an in-memory cloud-storage service that supports users, files, and prefix search. You must write a class (or set of classes) that offers the following capabilities:
addUser(userId: str, capacity: int) → bool – Create a new user with the given total byte capacity. Return true if the user was created, false if the userId already exists.
addFileBy(userId: str, fileName: str, fileSize: int) → bool – Add a file owned by the user. Return true only if (a) the user exists, (b) no file with that exact name already exists anywhere in the system, and (c) the user has enough remaining capacity. On success the user’s used capacity must increase by fileSize; otherwise the state is unchanged.
getFileSize(fileName: str) → int – Return the size of the file if it exists, else –1.
findFile(prefix: str) → List[str] – Return a list of all file names that start with the given prefix, sorted in ascending alphabetical order. If no files match, return an empty list.
removeFileBy(userId: str, fileName: str) → bool – Remove the file if it exists and is owned by the user. Return true on success; on success the user’s used capacity must decrease by the file’s size. Return false if the user does not exist, the file does not exist, or the file is not owned by that user.
The system must execute each operation in real time; there is no persistence requirement beyond the lifetime of the object.