Most Frequent Word across Grouped Arrays
Problem statement
Count every word occurrence across all rows of groups. Return the word with highest frequency, breaking ties lexicographically. Matching is case-sensitive. Return an empty string when there are no words.
Function
mostFrequentWord(groups: String[][]) → StringExamples
Example 1
groups = [["a","b"],["a","c"]]return = "a"Word a occurs twice across rows.
Example 2
groups = [["beta"],["alpha"]]return = "alpha"Lexicographic order resolves equal frequency.
Constraints
0 <= groups.length <= 10000- The total number of words is at most
100000.