Top 3 frequent words (case-insensitive, tie by lexicographic order)

Asked at Squarepoint · Coding Questions · Difficulty: Easy · Last asked Jul 15, 2026

Given a string `s` containing words separated by spaces and/or punctuation, count the occurrences of each word in a **case-insensitive** manner (e.g., "Apple" and "apple" are the same word).

Loading the problem…