Menu

Write Method Called Paircounts Accepts List Strings Representing Individual Words Counts N Q43881309

Write a method called pairCounts that accepts a list of stringsrepresenting individual words and counts the number of occurrencesof all 2-character sequences of letters in those words. Forexample, 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 itcontains no pairs.) Your method should count the occurrences ofthese pairs of letters and return the counts as a Map. In this caseyou would return {an=3, ba=1, be=1, ds=1, dy=1, en=2, me=1, na=2,nd=3, sa=1}. Notice that pairings that occur more than once in thesame word should be counted as separate occurrences. For example,”an” and “na” each occur twice in “banana”.

Expert Answer


Answer to Write a method called pairCounts that accepts a list of strings representing individual words and counts the number of o…

OR