FastPrepTop K Frequent Words
Problems/Top K Frequent Words

Top K Frequent Words

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in first-hand Bloomberg new-grad onsite interviews. Equal-frequency words are ordered lexicographically, matching the directly linked standard exercise.

Given an array words and integer k, return the k most frequent distinct words.

Rank words by descending frequency. If two words have the same frequency, the lexicographically smaller word ranks first.

Function

topKFrequentWords(words: String[], k: int) → String[]

Examples

Example 1

words = ["i","love","leetcode","i","love","coding"]k = 2return = ["i","love"]

Both occur twice, and i is lexicographically smaller.

Example 2

words = ["the","day","is","sunny","the","the","the","sunny","is","is"]k = 4return = ["the","is","sunny","day"]

Frequencies are 4, 3, 2, and 1.

Constraints

  • 1 <= words.length <= 10^5.
  • 1 <= k <= number of distinct words.
  • Words are nonempty lowercase English strings.

More Bloomberg LP Onsite Interview questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Running Stream AggregatesONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Top K Frequent ElementsCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Top K Frequent Elements with Larger-Value Tie BreakOracle · ONSITE INTERVIEWOracle interview questions
  • Top K Frequent ElementsInfosys · ONSITE INTERVIEWInfosys interview questions
  • Top-K IP Addresses from File RecordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Top K Keys from JSON RecordsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Streaming Top K Frequent ElementsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Top K Frequent ElementsEricsson · ONSITE INTERVIEWEricsson interview questions
  • Top-K KOLs by Total LikesTikTok · ONSITE INTERVIEWTikTok interview questions
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions

Interview reports that mention this question

  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg SWE Phone Screen and Onsite: 1 Experience

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[] topKFrequentWords(String[] words, int k) {
      // Write your code here.
    }
}
Checking account…