Design Log Storage System
The time complexity every time is N
I think you're including ':' too for cumulative effect in applying granularity, so Month granularity will simply bey "Year:Month:" while Hour granularity be "Year:Month:Day:Hour:". So ":" is deliberately included for ease in string comparison?
Similar idea with TreeMap.tailMap(Object fromKey)
No one has replied
@Aeonaxx The problem states "Unique timestamp", so a map is sufficient.
This solution is awesome!
the problem states "Given a log's unique id and timestamp". Suppose the timestamp is not unique, you can easily solve that by using id as key.
Same idea, but using stream:
Most of the top answers take O(N) time for retrieve, where N = number of total logs. It's OK when the data set is small.
But O(number of id in the result) will be significantly faster than O(N) when data set grows larger. Imaging you are trying to get 10 log records out of 10^12 total records.
Another advantage is, by using the Time Hierarchy Trie like structure, it's easy to store the log records in different files/computers without affecting the query efficiency.
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.