The interview lasted 45 minutes. We first went through my resume. I was asked about my most challenging project and the technology stack I normally use, and the interviewer introduced the work of the hiring group.
The remaining half hour was for coding. Given a series of file paths, I needed to build a directory tree and find the full path of a file in that tree. Directory names could repeat, but full paths would not.
At first, I used each complete path segment as a tree node. The interviewer asked what would happen if a path were especially long, so I changed the design to build the tree from node names. The final requirement was to avoid recursion and maintain a stack manually. I forgot the template and spent a long time debugging, so I did not finish and was rejected.
The input and paths shown were:
directories = ["/a", "/a/b", "/a/c/file1.txt", "/a/c/d", "/e", "/e/c", "/e/f/file2.txt"]
/a
/a/b
/a/b/c
/a/c/file1.txt
/e
/e/c
/e/f/file2.txt
Discussion
Loading comments…