Google L3/L4 Onsite Question

Given a CPU that can handle a max limit of CPU cycles a list of tasks where each task is [i,j,k] where i = enqueue time, j = duration, and k = cycles. Return whether or not we have a valid schedule.

Example:
tasks = [[0,5,5],[5,10,5]], limit = 5
True because CPU will schedule [0,5) and is under the limit, then [5,10) which is still under the limit since the task [0, 5) has been completed

tasks = [[0,5,5],[0,10,5]], limit = 5
False because limit is 5, and CPU will need a limit of 10 to schedule these tasks.

tasks = [[0,5,2],[5,10,5],[2,4,3],[4,5,1]] limit = 5
False because task [4,5,1] will cause CPU to exceed limit.

Similar to https://leetcode.com/problems/car-pooling/

Comments (3)