You have several logs, each with a unique identifier and a timestamp. The timestamp is formatted as YYYY:MM:DD:HH:MM:SS, such as 2018:02:15:14:30:45. All components are zero-padded numbers.
Design a system to store logs and support the following operations:
void addLog(int logId, string timeStamp): Store a log entry with the given unique ID and timestamp.
List<int> fetchLogs(String startTime, String endTime, String level): Return all log IDs whose timestamps fall within the range from startTime to endTime, inclusive. The level parameter indicates the granularity of the timestamp to consider (e.g., "Year", "Month", "Day", "Hour", "Minute", or "Second"). For example, if startTime = "2018:02:15:14:00:00", endTime = "2018:02:16:16:00:00", and level = "Day", then logs from February 15 and February 16 of 2018 should be included.
addLog(10, "2018:03:01:12:00:00");
addLog(20, "2018:03:01:11:30:00");
addLog(30, "2017:12:31:23:59:59");
fetchLogs("2017:12:31:00:00:00", "2018:03:01:12:00:00", "Year");
// Expected output: [10, 20, 30] because logs are within 2017 and 2018.
fetchLogs("2017:12:31:00:00:00", "2018:03:01:12:00:00", "Hour");
// Expected output: [10, 20] because only logs from 2018:03:01:11 and 2018:03:01:12 are included; log 30 is outside the hour range.
addLog and fetchLogs.