As reported: Epic Systems online assessment, 2026 — one of four programming questions.
Given a string s, count how many times each character occurs and return the counts as a map whose keys are in the order in which each character first appears in s.
- Counting is case-insensitive:
Aandaare the same character, reported in lowercase. - Spaces are ignored.
- Every other character (letters, digits, punctuation) is counted.
Example 1
s = "Amount Characters"
Output: a:3 m:1 o:1 u:1 n:1 t:2 c:2 h:1 r:2 e:1 s:1
a appears in "Amount" and twice in "Characters"; t and c appear once in each word.
Example 2
s = "Hello World"
Output: h:1 e:1 l:3 o:2 w:1 r:1 d:1
Constraints: 0 <= s.length <= 10^5; s contains printable ASCII characters.
Code runner format: one JSON string, s. Implement charFrequency(s) returning an ordered map of character → count: a dict in Python, a LinkedHashMap<Character, Integer> in Java, a Map in JavaScript, a vector<pair<char, int>> in C++, and a []CharCount in Go (CharCount has fields Char byte and Count int). The runner prints the entries as char:count separated by spaces, in your order.