Question: give me python code [ 7 : 1 0 PM , 8 / 2 7 / 2 0 2 4 ] Rituza: Question 1 Suppose

give me python code
[7:10 PM,8/27/2024] Rituza: Question 1
Suppose you are responsible for building a log server that will receive a large number of logs. Each log will have a log ID and timestamp. We want to keep track of these logs, but due to storage limitations, we can only return up to m logs from the last hour when requested.
Problem Statement
Complete the following functions
* recordLog(logld, timestamp): Records a new log entry.
* Each log is represented as an object with a logld and timestamp.
The logid 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.
* getLogs). Returns a comma separated string of the latest m logids from the last hour ascending by timestamp. In the event of a timestamp tie order from earliest received to latest.
o Return a string of the form "logld1, logld, logid3, logid4" where logld is the latest timestamp log and logld is the earliest timestamp log received <1 hour before logld4's timestamp getLogCount(: Returns the total number of logs received <1 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
Constraints
*15 ms 1000
*1<=q<=106
* logid is an integer
* timestamp is an integer representing a timestamp in seconds
[7:10 PM,8/27/2024] Rituza: left
ALL
2
*0
+
0
G
Hacker...
M
order.
8. COUNT: This returns the total number of logs in the last hour. We have four logs from the last hour, so it returns 4.
9. RECORD 43900: The log with ID 4 at timestamp 3900 is recorded.
10. GET LOGS: At this point, the logs with ID 1 at timestamp 0 and ID 2 at timestamp 300 are more than an hour old, so they are not included. The function returns 3,1,4- the IDs of the logs from the past hour in timestamp order.
* Sample Case 1
Sample Input For Custom Testing
2
RECORD 10
RECORD 7600
RECORD 31200
RECORD 51800
GET LOGS
COUNT
RECORD 22400
GET_ LOGS
COUNT
Sample Output
3,5
5,2
Explanation
1, RECORD 10: A log with ID 1 at timestamp 0 is recorded.
2. RECORD 7600: A log with ID 7 at timestamp 600 is recorded.
3, RECORD 31200: A log with ID 3 at timestamp 1200 is recorded.
4, RECORD 51800: A log with ID 5 at timestamp 1800 is recorded.
5. GET LOGS: With m set to 2, the function returns the latest two log IDs received in the last hour: 3,5.
6. COUNT: Returns the total number of logs from the last hour. At this time, there are four logs in the last hour, so it returns 4.
7. RECORD 22400: A log with ID 2 at timestamp 2400 is recorded.
8. GET LOGS: Again, the function returns the latest two log IDs received in the last hour, 5,2.
9. COUNT: Returns the total number of logs from the last hour. At this time, there are five logs in the last hour, so it returns 5.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!