Difficulty: Easy Tags: NLP
TikTok's hashtag-suggestion model needs a vocabulary built from raw captions before it can suggest
anything: take the k most frequent hashtags, everything else becomes <unk>.
Count hashtag frequency across all captions; return the top k by count, ties broken by earliest
first appearance in the input.
k
n
caption_1
...
caption_n
Hashtags are whitespace-separated tokens starting with #; non-hashtag words are ignored.
k lines (fewer if fewer than k distinct hashtags exist): hashtag count.
1 <= k <= 1000, 1 <= n <= 10^4Input
2
1
#fyp #dance #fyp #comedy #fyp #dance #viral
Output
#fyp 3
#dance 2
No results yet
Run your code to check it against the examples, or submit to run every test.