LC: 635. Design Log Storage System - spiralgo/algorithms GitHub Wiki
635. Design Log Storage System
The Essence:
The log storage data structure needs to be able to convert the given timestamps to some for of keys and then match this with the value of the id. Since the given date values are strings, the problem-solver needs to find a efficient way of handling this.
The second retrieval problem here also suggests that the data structure where the dates are kept should be efficient at returning its values in sorted order to manage the queries.
The granularity simply puts a limit to which order of time should be considered.
Details:
The given dates can be taken as they are and used as string keys in hash table. They can also be converted into numberic values and used as keys as such. For the retrieval, one can use sorted data structures like TreeMap of Java language or Binary Search Trees to efficiently return the values inside of a range. Normal hash tables are sufficient too.