Status: Software Engineer, 10 years of experience
Position: E5 at Facebook
Location: Menlo Park, CA
Date: September 10, 2019
Technical phone screen (45 min):
Onsite
Format: 5 rounds 45 min each
Result: Still waiting
Round 1: [Coding]
Round 2: [Coding]
Problem :
Given a char array representing tasks CPU need to do. It contains Integers where different integers represent different tasks. Tasks has to be done in original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.
However, there is a non-negative cooling interval K that means between two same tasks, there must be at least K intervals that CPU are doing different tasks or just be idle.
You need to return the total amount of time CPU will take to finish all the given tasks.
Example:
Input: tasks = ["1","2","1","2","2","1"], n = 2
Output: 9
Explanation: 1-2-idle-1-2-idle-idle-2-1
Time complexity of my solution was O(N) - N is the number of tasks and space complexity was O(T) - T is number of types of tasks.
I have been asked if I can optimize further on space if cooling period is very low. Interviewer was fine even if time complexity is a bit high. I proposed a different solution with O(K) as space complexity and O(NK) as time complexity. But didn't had time to implement it.
Lunch:
Round 3: [System Design]
Round 4: [Behavioral]
Round 5: [Coding]
Notes