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

 

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

One tool of basic cryptanalysis is determining how frequently any letter occurs in a given passage. From there, one can often determine the characteristics of a substitution cipher. Return the letter and frequency of the most-frequently occurring letter in the input in the form "letter=frequency". If multiple letters have the same highest frequency, return the first of those in the alphabet. Precondition: str will only contain capital letters.

HINT
You will probably need multiple loops for this method. Consider what data structure is best to store the frequency information.

apcsaEncryptHighestFrequency("AAA") → "A=3"
apcsaEncryptHighestFrequency("ABBCCCDDDDEEEEEFFFFFFGGGGGGG") → "G=7"
apcsaEncryptHighestFrequency("ZZZAAA") → "A=3"

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

public String apcsaEncryptHighestFrequency(String str) { }

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: 350

Copyright Nick Parlante 2017 - privacy