Question: Write a method called pairCounts that accepts a list of strings representing individual words and counts the number of occurrences of all 2-character sequences of

Write a method called pairCounts that accepts a list of strings representing individual words and counts the number of occurrences of all 2-character sequences of letters in those words. For example, suppose the list contains ["banana", "bends", "i", "mend", "sandy"]. This list contains the following two-character pairs: "ba", "an", "na", "an", "na" from "banana"; "be", "en", "nd", "ds" from "bends"; "me", "en", "nd" from "mend" ; and "sa", "an", "nd", "dy" from "sandy" . (Note that "i" is only one character long, so it contains no pairs.) Your method should count the occurrences of these pairs of letters and return the counts as a Map . In this case you would return {an=3, ba=1, be=1, ds=1, dy=1, en=2, me=1, na=2, nd=3, sa=1}.

Step by Step Solution

3.43 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static Map pairCounts List list Map map ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!