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

 

bryce.hulett@hotmail.com > consonantHistogram
prev  |  next  |  chance

Create a frequency map for only the consonants in a given string. To do this, use a reference string for easy look up: "bcdfghjklmnpqrstvwxyz". Your function should return an int[21] where: Index 0 is the count of 'b's Index 1 is the count of 'c's ...and index 20 is the count of 'z's. Ignore vowels (a, e, i, o, u), spaces, numbers, and case.


consonantHistogram("abc") → [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
consonantHistogram("Computer language design is just like a stroll in the park. Jurassic Park, that is.") → [0, 2, 1, 0, 3, 2, 2, 3, 4, 1, 3, 3, 0, 5, 7, 6, 0, 0, 0, 0, 0]
consonantHistogram("My software never has bugs. It just develops random features.") → [1, 0, 2, 2, 1, 1, 1, 0, 1, 2, 2, 1, 0, 4, 6, 4, 2, 1, 0, 1, 0]

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

public int[] consonantHistogram(String s){ }

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: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy