Objects Shared by Two Logs

Asked at Google

Reported by the problem's creator, not verified

Each log is a list of entries [timestamp, obj_id, client_id]: at time timestamp, client client_id used object obj_id. Both ids are strings, and the logs are not sorted.

Examples

  1. Example 1

    Input: log_a = [[1,"X","c1"],[2,"X","c2"],[3,"Y","c1"]], log_b = [[4,"X","c1"],[5,"Z","c2"]]

    Output: ["X"]

    Explanation: X appears in both logs and its clients across the two logs are c1 and c2, so it qualifies. Y appears only in log_a and Z only in log_b, so neither qualifies.

  2. Example 2

    Input: log_a = [[1,"p","c1"],[2,"q","c1"],[3,"r","c2"],[4,"r","c2"]], log_b = [[1,"p","c1"],[2,"q","c2"],[3,"r","c2"],[4,"s","c9"]]

    Output: ["q"]

    Explanation: p is used only by c1 and r only by c2, so each has a single client and neither counts. q is used by c1 in log_a and by c2 in log_b, giving it two clients, so it counts.

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.