Google swe sre Onsite round 1
Summary
I had an onsite interview for the SRE role at Google, where I was tasked with designing and implementing file system utility functions, including a crucial follow-up to delete an entire directory tree.
Full Experience
I recently had my first onsite interview round for the Software Engineer, Site Reliability Engineer (SRE) role at Google. The interview focused heavily on file system operations and design. I was initially asked to implement several core file system utility functions, which served as building blocks for a more complex problem. The primary challenge involved efficiently deleting a directory tree.
Interview Questions (2)
Implement the following file system utility functions which could be used to interact with a file system:
fs.GetDirectoryChildren(path): Given a path to a directory, return a list of its immediate children (files and subdirectories).fs.Delete(path): Delete a file or an empty directory at the given path.bool fs.IsDirectory(path): Determine if the given path corresponds to a directory.
As a follow-up, implement the function deleteDirectoryTree(path). This function should recursively delete a directory and all its contents (subdirectories and files) starting from the given path. You should leverage the previously defined file system utility functions like GetDirectoryChildren, Delete, and IsDirectory to achieve this efficiently.