Practice Find Total Time Spent by Each Employee
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Tables: Employees(emp_id INT, event_day DATE, in_time INT, out_time INT). Employees has key (emp_id, event_day, in_time). Entry and exit minutes lie from 1 through 1440, in_time is less than out_time, and an employee's daily intervals do not overlap. Return day, emp_id and total_time for each employee-date pair. Sum out_time - in_time across all entries that day; do not add an inclusive endpoint minute. Output order is unrestricted.
Source: Find Total Time Spent by Each Employee on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Employees table: +--------+------------+---------+----------+ | emp_id | event_day | in_time | out_time | +--------+------------+---------+----------+ | 1 | 2020-11-28 | 4 | 32 | | 1 | 2020-11-28 | 55 | 200 | | 1 | 2020-12-03 | 1 | 42 | | 2 | 2020-11-28 | 3 | 33 | | 2 | 2020-12-09 | 47 | 74 | +--------+------------+---------+----------+
+------------+--------+------------+ | day | emp_id | total_time | +------------+--------+------------+ | 2020-11-28 | 1 | 173 | | 2020-11-28 | 2 | 30 | | 2020-12-03 | 1 | 41 | | 2020-12-09 | 2 | 27 | +------------+--------+------------+
Related LeetCode Problems
Practice more problems similar to Find Total Time Spent by Each Employee.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.