Skip to content

Instantly share code, notes, and snippets.

@stesh
Created February 18, 2011 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stesh/833608 to your computer and use it in GitHub Desktop.
Save stesh/833608 to your computer and use it in GitHub Desktop.
public static int[] countLetters(String input) {
int[] results = new int[26];
for (int i = 0; i < input.length(); i++) {
int cur = input.toLowerCase().charAt(i);
if (cur >= 'a' && cur <= 'z') {results[cur - 'a']++;}
}
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment