Rank the Search Terms

Basic

A search-indexing step needs to know how often each term appears in a document so it can rank relevance.

Implement `solve(List<String> words)` to return a map of each distinct word to how many times it appears.

Examples

Input["a", "b", "a", "c", "a", "b"]
Output{a=3, b=2, c=1}
Input["x"]
Output{x=1}
Hints
  • Read the current count (0 if absent) and store count + 1.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.