Recently, I have interviewed with one of the High Frequency Trading (hft) firm and there was asked one question:-
Suppose, there is a bookapi that gets us the booknames which is bookapi.getBooks(). This api call has the latency = 500 ms(milliseconds) and there are 1k books in library. Subsequently, there is another call that we can make after finding the book name which get us the content of that particular book which can be done by bookapi.getText(bookname). The api call can send us 1 billion words per book which will have the latency = 1000 ms(milliseconds).
Now, if we have to find the count of a specific word in the book. For ex - "Ram" in "Ramayana" with the latency of 400 microseconds. How would we be able to do this? Any caching mechanism or custom data structure?