Word Frequency in a Large Text
Updated
Problem statement
Given a large string text, split it into words using punctuation characters and whitespace as separators.
Result Rules
- Matching is case-insensitive.
- Punctuation is not part of a word.
- Return each result as
"word frequency"using the lowercase word. - Sort by descending frequency. When frequencies are equal, sort the words lexicographically.
Function
wordFrequency(text: String) → String[]Examples
Example 1
text = "hello world, hello computer"return = ["hello 2","computer 1","world 1"]hello appears twice. computer and world appear once, so their tie is resolved lexicographically.
More Robinhood interview questions
- Top Ten Most Frequent Words in a BookPHONE SCREEN · Seen Oct 2026
- Fractional Share Inventory FlatteningPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Unique Transitive Dependent CountsPHONE SCREEN · Seen Sep 2026
- Service Dependency Load FactorsPHONE SCREEN · Seen Sep 2026
- Earliest One-Hour Badge Alert TimesPHONE SCREEN · Seen Sep 2021
- Courses Shared by Every Student PairPHONE SCREEN · Seen Sep 2019
- Middle Course in One Prerequisite ChainPHONE SCREEN · Seen Sep 2019
- Friendship and Balance TrackerONSITE INTERVIEW · Seen Sep 2026
- Transitive Employee Referral CountsONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Best Anagram MatchGoogle · PHONE SCREENGoogle interview questions
- Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
- Rank Words by FrequencyDatadog · PHONE SCREENDatadog interview questions
- Sort Letters by FrequencyScale AI · PHONE SCREENScale AI interview questions
- Average Process Time from CSVAbnormal Security · PHONE SCREEN