Google Interview Question
SDE1sCountry: United States
When it means data is on disk, it means that size of the data is not known and is probably very large. Like a 1GB file. In such case we can used a circular buffer (circular linked list say size N) to read a chunk of data in the buffer and slide the window of size k to get the sum. As we reach the end of buffer, we can read N-K chunk of data in the buffer and keep adding the data in head to the sliding window.
- an idea but its a bit slow May 19, 2017