Algorithm · Google · Hard
Given a sequence of words, solve the following related tasks. Part 1 — Top and bottom k words by frequency You are given an array words and a non-negative integer k. Return two lists: the k distinct words with the largest frequencies, and the k distinct words with the smallest frequencies. When two words have the same frequency, order them lexicographically ascending. If fewer than k distinct words exist, return all distinct words in the requested order. String comparison is…
Checking your access…