Working Hours Register
Asked at Airbnb
Reported by the problem's creator, not verified
You are building a register of employee working hours as the class WorkingHoursRegister.
Examples
Example 1
Input: init =
[], operations =[["add_employee",["e1","dev",10]],["enter",["e1",3]],["get_worked_time",["e1"]],["exit",["e1",8]],["get_worked_time",["e1"]],["add_employee",["e2","qa",7]],["get_worked_time",["e2"]],["enter",["e2",0]],["exit",["e2",0]],["enter",["e2",10]],["exit",["e2",14]],["enter",["e2",20]],["exit",["e2",21]],["get_worked_time",["e2"]],["get_worked_time",["e1"]]]Output:
[null,null,0,null,5,null,0,null,null,null,null,null,null,5,5]Explanation:
e1checks in at 3, and while the session is open the worked time is 0. After checking out at 8 it is 5.e2has three finished sessions of lengths 0, 4 and 1, so 5; before the first check-in it was 0.