LinkedIn-inspired text analytics service is building a lightweight vocabulary report from a batch of documents. You need to count token occurrences consistently so the team can identify the most frequent terms for the next modeling stage.
Count how many times each token occurs and return the counts as a dict. Keys appear in order of first occurrence.
Implement solve(tokens).
Returns. Return a dict {token: count}; an empty list gives an empty dict.
Example 1
Input:
solve([2, 1, 2, 3, 2, 1])
Output:
{2: 3, 1: 2, 3: 1}
Example 2
Input:
solve(['a', 'b', 'a'])
Output:
{'a': 2, 'b': 1}
No results yet
Run your code to check it against the examples, or submit to run every test.