Character Frequencies Across Nested String Lists
Updated
Problem statement
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^30 <= groups[i].length <= 10^3- Across all inner arrays, there are at most
10^4strings. - Across all strings, there are at most
2 * 10^5characters. - 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