Back to problems

Query Log Matching

Algorithm · Datadog · Medium

You are monitoring a live text stream liveInputStream consisting of interleaved queries and logs: A query event has the shape "Q: ". A log event has the shape "L: ". Walk through the events in the order they appear and perform the following actions for each one. When you encounter a query: Assign it the next sequential integer ID, beginning at 1, based on how many queries have been seen so far. Issue an acknowledgment formatted as "ACK: ; QID= ". When you encounter a log:…

Checking your access…