Working Hours Register

Asked at AirbnbOnline assessment

Reported by the problem's creator, not verified

You are building a register of employee working hours as the class WorkingHoursRegister.

Examples

  1. 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: e1 checks in at 3, and while the session is open the worked time is 0. After checking out at 8 it is 5. e2 has three finished sessions of lengths 0, 4 and 1, so 5; before the first check-in it was 0.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.