Datadog logo

Datadog

New York, NYSoftware

Interview Questions

Implement BufferedFile Class

Asked at Datadog
phone
coding
phone

Implement a BufferedFile class, simulating a memory storage system.

Assume that you have the following helper functions:

write(const uint8_t* bytes, int nBytes): Write data to memory. When memory is full, follow FIFO (First In First Out) to write from memory to disk.

flush(): Transfer data from memory to disk.

Constructor: BufferedFile(File* f, int nMaxBufferedBytes), where nMaxBufferedBytes indicates the memory size.

Implement Unix Command rm -rf

Asked at Datadog
onsite
coding
onsite

Implement functionality akin to the Unix command rm -rf, which recursively deletes all content in a specified path.

Assume that you have the following helper functions:

FindList(string path): Find all subdirectories and files in the current path.

Delete(string path): If the path is a file or an empty directory, delete it and return true.

isDir(string path): Return true if the path is a directory.

Solution Approach: Recursion. Follow-up Question: Handling out-of-memory issues.

Share Your Experience at Datadog