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.

  1. given a current working director and a path (which could be relative or absolute) I need to give the new working directory.
  • My Approach - i have used Deque to solve this. initially populated deque from the working director and then moved on the path. I have checked if the path is absolute then I cleared the deque and have pushed the elements to back and have popped from the front to build the current director using string builder.

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

  1. Search in a SkipList
Node{
int val;
Node nextNode;
Node[] skipList;
}

search(Node node, int target)

I was asked for an efficient search in this SkipList.

  • My Approach: I told I will use a recurssive approach, where for each node I will get the node whose value is just smaller than or eqaul to the target (using a loop from n-1 to 1 in skipList) and the base conditons would be if Node val is equal to target return true, and if there is no more recurssions possible in skipList return false.

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

Comments (6)