Facebook | Phone | Time to finish task & Basic Calculator

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-11-25Added By Anonymous
Source: Link

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

Original Post Content:

Question 1:
Given a list of tasks (which have a name and an execution time) and a list of dependencies between those tasks (graph), find the total time it takes for a certain task to finish.
For example:
Tasks: A B C D E
Time: 5 2 4 1 3
Dependencies:
A cannot execute until B and C have finished
B cannot execute until D and E have finished
C cannot execute until E has finished

Find the total time it takes A to execute.
Answer: time(E) + time(C) + time(D) + time(B) + time(A) = 15

I suggested a topological sort, but the interviewer said that the sum will still be the same, so I don't need to sort the tasks. He wanted me to do a BFS.

Question 2:
https://leetcode.com/problems/basic-calculator-ii/

Comments