I recently gave a phone interview for Meta (L4). The questions asked to me were different to the questions posted in the commity, so sharing my experience.
follow - up: asked if I can use any other ds, I mentioned stack and defended my approach as using stack would make the implementation tricky to build the final directory.
tc:
current path output
/def /abc /abc
/abc/def ../ghk /abc/ghk
/sbc/def ../../../../. /Similar Question on leetcode - https://leetcode.com/problems/simplify-path
Node{
int val;
Node nextNode;
Node[] skipList;
}
search(Node node, int target)I was asked for an efficient search in this SkipList.
asked for the TC of the Approach:
I told it is a log operation. (in the test case given, each node has skiplist to nodes at position 2, 4, 8, 16, .... )
Result - Rejected