Question: I want cpp code Suppose you are responsible for building a log server that will receive a large number of logs . Each log will
I want cpp code
Suppose you are responsible for building a log server that will receive a large number of logsEach log will have a log ID and timestamp. We want to keep track of these logsbut due to storage limitationswe can only return up to m logs from the last hour when requested.
Problem Statement
Complete the following functions
recordLoglogldtimestamp: Records a new log entry.
Each log is represented as an object with a logld and timestalap. The logld is an identifier for each log and the timestamp is an integer in seconds representing when the log was sent.
Logs may be received out of order
The log ID is not guaranteed to be unique the same log ID can be used for different logs
getLogsReturns a comma separated string of the latest m loglds from the last hour ascending by timestamp. In the event of a timestamp tie order from earliest received to latest.
Return a string of the form
"logldlogldlogidlogldwhere logldis
the latest timestamp log and logldis the earliest timestamp log received hour before loglds timestamp
getLogCount: Returns the total number of logs received hour from the most recently stored log timestamp. In the event more than m logs have been received still return the full count of logs
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
