目录

力扣192. 统计词频

力扣192. Word Frequency(统计词频)

写一个 bash 脚本以统计一个文本文件 words.txt 中每个单词出现的频率。为了简单起见,你可以假设 words.txt 只包含小写字母和空格。每个单词只由小写字母组成,单词间由一个或多个空格字符分隔。

示例 1:

../posts/01_学习/87_LeetCode/0192_统计词频/img/0192-1-description.png

假设 words.txt 内容如下:
the day is sunny the the
the sunny is is

输出(按词频降序排列):
the 4
is 3
sunny 2
day 1

提示:

  • 输出结果中每行为 单词 频次,用空格分隔
  • 按词频降序排列(频次相同则按字母顺序升序)