Library Checkout Log

Asked at MetaPhone screen

Reported by the problem's creator, not verified

A library records what happens to its books as a list of events. Each event is [timestamp, book_id, member_id, action], where timestamp is a decimal string of an integer and action is one of "checkout", "return" or "renew".

Examples

  1. Example 1

    Input: events = [["1","b1","m1","checkout"],["2","b1","m1","renew"],["3","b1","m1","return"],["4","b1","m2","checkout"]]

    Output: [true,-1]

    Explanation: m1 checks b1 out, renews it and returns it. After the return the book is free, so m2 may check it out at time 4. Every event is allowed, so the answer is [True, -1].

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.