FastPrepCharacter Frequencies Across Strings
Problems/Character Frequencies Across Strings

Character Frequencies Across Strings

Snowflake logoSnowflake● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamples

Problem statement

Source note: The source asks for character frequencies across a list of strings without using a built-in frequency counter. It supplies ["hello", "world"] and the counts h:1, e:1, l:3, o:2, w:1, r:1, d:1, but it does not define a cross-language map representation, deterministic row order, or character domain. The judged core task matches the visible source at about 95%.

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

  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public String[][] characterFrequencies(String[] strings) {
      // write your code here
    }
}
Checking account…