彭博面试题:在莎士比亚作品文件夹中统计单词出现次数与行号

61次阅读
没有评论
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.
正文完
 0