So, I interviewed with Facebook yesterday through a virtual onsite. The questions were pretty much same from LC tagged but there was this question that catches my mind.
It looks similar to https://leetcode.com/problems/find-duplicate-file-in-system/ but here we don't have content of file to match, we need to return the list of paths which are non-redundant. A path is redundant if it's root already present in the list.
Example 1:
Input = ["/a/b/c","/a/b","/d/e","/d"]
Expected output = ["/a/b" , "/d"]
Example 2:
Input = ["/a/b/d","/a/b/f","/d/e","/d"]
Expected output = ['/a/b/d', '/a/b/f', '/d']
I tried asking my interviewer, like how we define root here is it just one directory after first '/', but he didn't utter a single word.
Can someone help me with this one ?