Objects Shared by Two Logs
GoogleEasy
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.
Part 1: Objects used by two clients in both logs
You are given two access logs, log_a and log_b. Every entry is [timestamp, obj_id, client_id], meaning client client_id used object obj_id at time timestamp. Both ids are strings, and neither log is sorted.
Return every obj_id that appears in both logs and was used by at least two different clients when the two logs are combined. Return each such id once, in ascending string order.
A client counts once no matter how many times it uses an object, and its uses in either log count: an object touched by c1 in log_a and by c2 in log_b has two clients. Timestamps do not affect the answer.
- Example 1
- log_a
[[1,"X","c1"],[2,"X","c2"],[3,"Y","c1"]]- log_b
[[4,"X","c1"],[5,"Z","c2"]]- Output
["X"]
Why:
Xappears in both logs and its clients across the two logs arec1andc2, so it qualifies.Yappears only inlog_aandZonly inlog_b, so neither qualifies. - Example 2
- 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"]
Why:
pis used only byc1andronly byc2, so each has a single client and neither counts.qis used byc1inlog_aand byc2inlog_b, giving it two clients, so it counts.
Constraints
0 <= len(log_a), len(log_b) <= 10^51 <= len(obj_id), len(client_id) <= 200 <= timestamp <= 10^9- Each entry is
[timestamp, obj_id, client_id]