Algorithm · Airtable · Medium
You have data for n employees, labeled 0 through n-1. Two integer arrays of length n are provided: cansConsumed[i]: the number of sparkling-water cans employee i drank in the past year. manager[i]: the direct manager of employee i, or -1 if this employee has no manager. Define a team as all employees who ultimately report to the same manager (following the chain of direct and indirect reports upward). The shared manager is not counted as a member of the team. The hydration…