Manager of the Largest Department
You are given an employees table represented as a 2D array of strings, where each row is employees[i] = [emp_id, emp_name, dep_id, position].
A department's size is the total number of employees whose dep_id belongs to that department. The largest department is any department with the maximum size among all departments.
Return the names of all employees whose position is "Manager" and whose dep_id belongs to a largest department. If multiple departments are tied for the largest size, include managers from all tied departments. The answer may be returned in any order.
employees = [["1","Alice","101","Manager"],["2","Bob","101","Engineer"],["3","Charlie","102","Manager"],["4","David","102","Engineer"],["5","Eve","102","Engineer"]]["Charlie"]employees = [["1","Maya","10","Manager"],["2","Noah","10","Engineer"],["3","Liam","20","Manager"],["4","Olivia","20","Analyst"],["5","Emma","30","Manager"]]["Maya","Liam"]Constraints
- 1 <= employees.length <= 10^4
- employees[i].length == 4
- employees[i] = [emp_id, emp_name, dep_id, position]
- emp_id and dep_id are string representations of positive integers
- All emp_id values are unique
- 1 <= emp_name.length, position.length <= 100
- position is "Manager" for managers
Asked at 1 companies
Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.