Redian新闻
>
Hot startup coding test 的问题
avatar
Hot startup coding test 的问题# JobHunting - 待字闺中
j*r
1
一家hot startup,coding question:
Write a function that takes two parameters: (1) a String representing a text
document and (2) an integer providing the number of items to return.
Implement the function such that it returns a list of Strings ordered by
word frequency, the most frequently occurring word first. Use your best
judgement to decide how words are separated. Your solution should run in O(n
) time where n is the number of characters in the document. Implement this
function as you would for a production/commercial system. You may use any
standard data structures.
有什么好的解法吗?
avatar
k*o
2
不能hashmap统计词频后 用MinPQ 滤掉其他的么
avatar
j*r
3
我就是这样做的,但是被告知不满意。 是否有更好的解法?

【在 k*****o 的大作中提到】
: 不能hashmap统计词频后 用MinPQ 滤掉其他的么
avatar
s*x
4

Hashmap 统计之后就成了单纯的排序问题了,我想可以用selection algorithm for
top k.

【在 j*******r 的大作中提到】
: 我就是这样做的,但是被告知不满意。 是否有更好的解法?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。