The TransCompilator

Solved LeetCode program · 998 of 1,000

#1376 · Time Needed to Inform All Employees

Medium Depth-First Search chunk-20.md

Original English source

Keep a shared manager holding 2, 2, -1, 2, 2, and 2. Keep a shared informTime holding 0, 0, 1, 0, 0, and 0. Keep a shared total of 0. Keep a shared best of 0.

To measure from employee (a whole number). Set total to 0. The current is employee.
Repeat while item current of manager is not -1.
The boss is item current of manager. Increase total by item boss of informTime. Set current to boss.

For every employee from 0 to 5.
Measure from employee. If total is more than best, set best to total.

Show best.

Open in Playground Browse all 1,000 problems

Expected stdout

1