You are given a collection of log entries, where each entry consists of a unique id and a timestamp. The timestamp is a string in the format Year:Month:Day:Hour:Minute:Second (for example, 2018:07:14:09:21:00). All fields are zero-padded numbers.
Design a logging system with the following methods:
void addLog(int logId, String time): Stores a log identified by logId and its time in the system.List<Integer> getLogs(String startTime, String endTime, String granularity): Returns the list of logIds sorted in ascending order whose timestamps are in the range from startTime to endTime (inclusive), considering only up to the specified granularity ("Year", "Month", "Day", "Hour", "Minute", or "Second").addLog(11, "2018:07:14:09:21:00");
addLog(22, "2018:07:14:08:59:00");
addLog(33, "2017:06:01:12:00:00");
getLogs("2017:01:01:00:00:00", "2018:12:31:23:59:59", "Year"); // returns [11,22,33]
getLogs("2018:07:14:00:00:00", "2018:07:14:09:00:00", "Hour"); // returns [22]