← 返回 roblox 的题目列表Log Timestamp Counting
类型:online_judge
roblox
Given a series of log entries, each with a timestamp. Your task is to design a system to efficiently count the number of log entries within a given time interval. Additionally, the system should support operation in a distributed environment.
Function Requirements:
Initialize the log system.
Add a log entry to the system, where each entry includes a timestamp.
Query the total number of log entries recorded within a specified start and end time.
The query implementation should efficiently operate in a distributed system.
Input/Output Example:
Example 1:
Input:
init
add 1622530800
add 1622534400
add 1622538000
query 1622530800 1622538000
Output:
3
Constraints:
Timestamps are non-negative integers.
Each request is on a separate line: init for initializing the log system, add <timestamp> for adding a log timestamp, query <start> <end> for querying the number of logs in a specified time span.
Assume that in a single machine implementation, data synchronization across distributed systems occurs automatically after each add operation.
Example
Input
init
add 1622530800
add 1622534400
add 1622538000
query 1622530800 1622538000