Character Frequencies Across Strings
Learn this problemProblem statement
Given an array of printable ASCII strings, count the total number of occurrences of every character across all strings.
Return the frequency map as a two-column String[][]. Each row must be [character, count], where character is a one-character string and count is its decimal frequency. Order rows by the first appearance of each character while scanning the input strings from left to right.
Characters are case-sensitive, and spaces and punctuation are counted like any other printable ASCII character. If no character appears, return an empty matrix. Do not use a built-in frequency-counter utility such as Python's Counter.
Function
characterFrequencies(strings: String[]) → String[][]Examples
Example 1
strings = ["hello","world"]return = [["h","1"],["e","1"],["l","3"],["o","2"],["w","1"],["r","1"],["d","1"]]Scanning left to right first discovers h, e, l, o, w, r, d. Across both strings, l occurs three times and o occurs twice; every other discovered character occurs once.
Example 2
strings = ["Aa!"," A"]return = [["A","2"],["a","1"],["!","1"],[" ","1"]]Uppercase A and lowercase a are distinct. Punctuation and the space are counted, and rows retain first-appearance order.
More Snowflake problems
- Closest Target CharacterPHONE SCREEN · Seen Jul 2026
- Horizontal Pod AutoscalerSeen Jul 2026
- Minimum HeightOA · Seen Jul 2026
- Vowel SubstringSeen Jun 2026
- String Formation (Also for AI/ML Software Engineer Intern :)OA · Seen Jun 2026
- Efficient DeploymentsOA · Seen Jun 2026
- Character Frequencies Across Nested String ListsPHONE SCREEN · Seen Jun 2026
- Top Two Users by Total Purchase AmountPHONE SCREEN · Seen Jun 2026