首页 > 试题广场 >

词频统计

[编程题]词频统计
  • 热度指数:7490 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

给定一个string数组article及其大小n及一个待统计单词word,请返回该单词在数组中出现的频数。文章的词数在1000以内。

python solution

return article.count(word)
发表于 2017-10-01 22:53:22 回复(2)
class Frequency:
    def getFrequency(self, article, n, word):
        return article.count(word)

发表于 2016-12-29 07:32:15 回复(0)
class Frequency:
    def getFrequency(self, article, n, word):
        # write code here
        count = 0
        for item in article:
            if item == word:
				count += 1
        return count

发表于 2016-11-19 22:29:24 回复(0)

问题信息

难度:
3条回答 21290浏览

热门推荐

通过挑战的用户

查看代码