4 ms·
An interview could reasonably ask for an out-of-core solution. But you are right that optimizing specifically for two files seems wrong, especially as the data
by gpderetta 3y ago
An interview could reasonably ask for an out-of-core solution.
But you are right that optimizing specifically for two files seems wrong, especially as the data contains a timestamp, so you could simplify the problem and ignore the number of files completely.
- xoranth 3y agoYou can generalize to > Now, given two N log files we want to generate a list of ‘loyal customers’ that meet the criteria of: (a) they came on ALL days, and (b) they visited at least L unique pages. while keeping linear time complexity and O(num records in first file * L) memory complexity. It is not too different from the solution given in the article (just use 3 maps instead of two). That means that multiple files doesn't need out-of-core if the maps for one file at a time fit memory.