FastPrepCharacter Frequencies Across Nested String Lists
Problems/Character Frequencies Across Nested String Lists

Character Frequencies Across Nested String Lists

Snowflake logoSnowflake● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Snowflake phone screen. The report asks how the character-frequency task changes when the input is a nested list. The nested example in the report is cropped. It does not say how deep the nesting goes, in what order to walk it, what shape the result takes, which characters can appear, or what to do with empty input. Our version is about 85% the same as the reported question.

Given a two-level array of string groups, count the total number of occurrences of every character across every string.

Traverse the outer array from left to right, each inner array from left to right, and each string from left to right. 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 during that traversal.

Characters are case-sensitive, and spaces and punctuation are counted like any other printable ASCII character. Empty inner arrays and empty strings are allowed. If no character appears, return an empty matrix. Do not use a built-in frequency-counter utility such as Python's Counter.

Function

nestedCharacterFrequencies(groups: String[][]) → String[][]

Examples

Example 1

groups = [["hello"],["world"]]return = [["h","1"],["e","1"],["l","3"],["o","2"],["w","1"],["r","1"],["d","1"]]

The traversal first visits "hello" and then "world". It first discovers h, e, l, o, w, r, d; l occurs three times, o occurs twice, and every other character occurs once.

Example 2

groups = [["Aa",""],[],["!A"," a"]]return = [["A","2"],["a","2"],["!","1"],[" ","1"]]

The empty string and empty inner array contribute no characters. Uppercase A and lowercase a are distinct, and the exclamation mark and space are counted in first-appearance order.

Example 3

groups = [[],[""],[]]return = []

No string contains a character, so the frequency matrix is empty.

Constraints

  • 0 <= groups.length <= 10^3
  • 0 <= groups[i].length <= 10^3
  • Across all inner arrays, there are at most 10^4 strings.
  • Across all strings, there are at most 2 * 10^5 characters.
  • Every string contains only printable ASCII characters.

More Snowflake Phone Screen questions

  • Minimum StackPHONE SCREEN · Seen Nov 2026
  • Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
  • Merge Two Binary TreesPHONE 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
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
  • Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
  • Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • Most Frequent NameAmazon · PHONE SCREEN
  • Words with Repeated AnagramsThe Voleon Group · PHONE SCREEN
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Product Keyword SearchTesco · PHONE SCREEN
  • Verify Words Sorted by a Custom AlphabetTrueFoundry · PHONE SCREEN
  • Neighboring Record IDsZipRecruiter · PHONE SCREENZipRecruiter interview questions

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public String[][] nestedCharacterFrequencies(String[][] groups) {
      // write your code here
    }
}
Checking account…