Bloomberg Interview Question: Word Occurrence Search Across Shakespeare Files

11 Views
No Comments
shakspear publish lot of work, given a folder of files of shakspear's work,
implement a command line tool that takes a word and shows how many times that 
word appeared in each file and on which line number

This problem asks you to design a command-line tool that, given a directory of Shakespeare text files and a target word, scans every file and reports:

  1. how many times the word appears in that file, and
  2. which specific line numbers contain the word.
    This is essentially implementing a simplified version of grep + counting, requiring directory traversal, file reading, line-by-line scanning, and case-sensitive or case-insensitive matching depending on spec.
END
 0