This is an interview question, and should concern about efficiency. How to calculate occurrences of specified word in a large text file? I can only think of indexOf() method in most programming languages, but I don’t think that the correct answer.
This is an interview question, and should concern about efficiency. How to calculate occurrences
Share
What you want is the Boyer-Moore algorithm. It is the most efficient known general method for this problem.