Character Frequencies Across Strings
Updated
Problem 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 Phone Screen questions
- 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
- Greedy Person-Cake Matching DistancePHONE SCREEN · Seen Nov 2026
- Tree Height After Child PromotionPHONE SCREEN · Seen Oct 2026
- Minimum StackPHONE SCREEN · Seen Oct 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