Write a function to return the top N frequent words and their frequencies from a given paragraph string, and determine the function’s run-time.
Write a function to return the top N frequent words and their frequencies from a given paragraph string, and determine the function’s run-time.
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: medium
分类: problem-solving
标签: Backend, Java/Kotlin/Python
目标岗位: Software Engineer
目标公司: Atlassian
参考答案摘要
分词→用哈希表统计词频→取 Top N:可对唯一词 m 做排序 O(m log m),或用最小堆做到 O(m log N)。总复杂度取决于分词成本与 m 的大小。
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。