about | help | code help+videos | done | prefs |
Write a method that returns an array indicating the frequency of occurrence of each letter and the frequency of occurrence of all other symbols, lumped together. The array that gets returns will have exactly 27 integers, with the integer at index 0 indicating how many times "A" occurred, the integer at index 1 indicating how many times "B" occurred, and so on until the integer at index 25 indicating how many times "Z" occurred. There is also an integer at index 26, which represents how many times all other symbols occurred. So, all other symbols get lumped together and counted at index 26. For this problem, both capital and lower-case letters count the same. It is the type of letter that matters, not its case. So "A" and "a" both count in index 0. Please do NOT hard-code any ASCII or UNICODE values. This problem does NOT need 27 conditional statements or anything crazy like that. Look at the test data for examples. test2024_01_22_SLHL_ltrFreq("The quick brown fox jumped over the lazy dogs.") → [1, 1, 1, 2, 4, 1, 1, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 9] test2024_01_22_SLHL_ltrFreq("Once, I thought I was wrong... but it turns out I was mistaken.") → [3, 1, 1, 0, 2, 0, 2, 2, 5, 0, 1, 0, 1, 4, 4, 0, 0, 2, 4, 7, 4, 0, 3, 0, 0, 0, 17] test2024_01_22_SLHL_ltrFreq("") → [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy