Remove Sub-Folders from the Filesystem
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a list of distinct folder paths. Each path starts with / and is a sequence of folder names separated by /, for example /a/b. A folder X is a *sub-folder* of folder Y when X begins with Y followed by a /. So /a/b is inside /a, but /ab is not.
Remove every folder that is a sub-folder of some other folder in the list, and return the remaining folders sorted in ascending lexicographic order.
Examples
Constraints
- 1 <= folder.length <= 4 * 10^4
- 2 <= folder[i].length <= 100
- Folder names contain only lowercase letters
- Every path starts with `/`, has no trailing `/`, and all paths are distinct
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.