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

 

alphaHistogram


Given a string, return an int[26] array representing the frequency of each lowercase alphabetical character ('a' through 'z'). Ignore case (treat 'A' as 'a') and ignore any non-alphabetical characters like spaces or punctuation. Index 0 should store the count of 'a's. Index 1 should store the count of 'b's. ...and so on, until Index `25) storing 'z's.


alphaHistogram("abc") → [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
alphaHistogram("An escalator can never truly break down, only become stairs, sorry for the convenience.") → [6, 2, 5, 1, 10, 1, 0, 1, 2, 0, 1, 3, 1, 8, 7, 0, 0, 8, 4, 4, 1, 2, 1, 0, 3, 0]
alphaHistogram("I've had amnesia for as long as I can remember") → [6, 1, 1, 1, 5, 1, 1, 1, 3, 0, 0, 1, 3, 3, 2, 0, 0, 3, 3, 0, 0, 1, 0, 0, 0, 0]

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

public int[] alphaHistogram(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