A word is a maximal continuous sequence of letters ('a'-'z'). Words are separated by spaces.
A digram is a string of length two. A word is said to contain digram "xy" if it contains an 'x'" immediately followed by 'y'. For example, the word "coder" contains digram "od" but doesn't contain digram "oe".
Consider text that consists of one or more words. The most frequent digram in text is the one that is contained in maximal number of words.
Given a piece of text, the most frequent digram is defined as the one that occurs in the greatest number of words. You are given a String[] chunks. Concatenate all elements of chunks to produce one long String of text. Return the most frequent digram in this text. If there are multiple possible answers, return the one among them that comes earliest alphabetically.
|