id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaMostCommonWord
prev  |  next  |  chance

Given an ArrayList of words (all uppercase letters) that all have the same length, create and return an output "word" where each letter is the most frequently-occurring letter of the input words, at that index. So with the words:

[SOW, SON, PIG, DOG, ABS]
the output would be "SOG" since S is the most-frequent letter at index 0, O is most-frequent at index 1, and G is most-frequent at index 2. In the case of a tie between two or more letters that occur with the same frequency, use the letter earliest in the alphabet. Preconditions: words has at least one element, all elements of words are uppercase letters of the same length.

apcsaMostCommonWord(["SOW", "SON", "PIG", "DOG", "ABS"]) → "SOG"
apcsaMostCommonWord(["ABC", "DEF", "GHI", "JKL", "MNI"]) → "ABI"
apcsaMostCommonWord(["GAUNT", "TOUTS", "LADEN", "OVARY", "MYTHS", "SAVOR", "JAZZY", "KAFIR", "JAMBS", "UNHIP", "COXED", "POLKA", "TRILL", "HOLEY", "CONEY", "ALLOY", "SHELF", "RAMIE", "PLASH", "QUOIT", "SOAVE"]) → "SAAEY"

...Save, Compile, Run (ctrl-enter)

public String apcsaMostCommonWord(ArrayList<String> words) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 330

Copyright Nick Parlante 2017 - privacy