Facebook | Phone | Change Working Directory

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-03-28Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: E3, E4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given current directory and change directory path, return final path.

For Example:

Curent Change Output

/ /facebook /facebook
/facebook/anin ../abc/def /facebook/abc/def
/facebook/instagram ../../../../. /

I solved it using stack but unfortunately it took me almost 40 minutes to come up with the solution. Last 5 minutes we discussed about life at facebook.

Generally, Facebook want us to solve 2 question in 45 minutes.
Got Rejected after 2 days.

Related problems:
* https://leetcode.com/problems/simplify-path/

Comments