1978. Employees Whose Manager Left the Company LeetCode Solution
In this guide, you will get 1978. Employees Whose Manager Left the Company LeetCode Solution with the best time and space complexity. The solution to Employees Whose Manager Left the Company problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Employees Whose Manager Left the Company solution in C++
- Employees Whose Manager Left the Company solution in Java
- Employees Whose Manager Left the Company solution in Python
- Additional Resources

Problem Statement of Employees Whose Manager Left the Company
Table: Employees
+————-+———-+
| Column Name | Type |
+————-+———-+
| employee_id | int |
| name | varchar |
| manager_id | int |
| salary | int |
+————-+———-+
In SQL, employee_id is the primary key for this table.
This table contains information about the employees, their salary, and the ID of their manager. Some employees do not have a manager (manager_id is null).
Find the IDs of the employees whose salary is strictly less than $30000 and whose manager left the company. When a manager leaves the company, their information is deleted from the Employees table, but the reports still have their manager_id set to the manager that left.
Return the result table ordered by employee_id.
The result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
1978. Employees Whose Manager Left the Company LeetCode Solution in C++
SELECT Employee.employee_id
FROM Employees AS Employee
LEFT JOIN Employees AS Manager
ON (Employee.manager_id = Manager.employee_id)
WHERE
Employee.salary < 30000
AND Employee.manager_id IS NOT NULL
AND Manager.employee_id IS NULL
ORDER BY 1;
/* code provided by PROGIEZ */
1978. Employees Whose Manager Left the Company LeetCode Solution in Java
N/A
// code provided by PROGIEZ
1978. Employees Whose Manager Left the Company LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.