Company: Uber_5_feb
Difficulty: medium
Optimal Execution Sequence Optimal Execution Sequence Description At Uber, Priya is known for being extremely systematic in how she rolls out internal platform changes. For an upcoming quarter, her manager assigns her n tasks. Some tasks depend on another task. Priya must arrange the tasks into a linear execution sequence. A task is counted as valid if and only if its prerequisite task appears earlier in the sequence. Tasks with no prerequisites are always valid. Each task depends on at most one other task. Only valid executed tasks count as completed tasks. Help Priya determine the maximum number of tasks she can complete by choosing the optimal execution sequence. Example Priya has n = 7 tasks to complete. Her manager provides m = 6 dependency notes describing the required task order. These dependencies can be represented as a directed graph. The dependent tasks array is a = [1, 2, 3, 4, 6, 5] . The prerequisite tasks array is b = [7, 6, 4, 1, 2, 1] . This forms a dependency graph am