Count occurrences
EasyGiven a list of words, write a function that returns a dictionary. Each key is a word. Each value is how many times that word appears.
For example, given
["dog", "cat", "dog"]
Your function should return
{"dog": 2, "cat": 1}
The order of keys doesn't matter.
Try it first
Solution
7 Essential DSA in the AI era Coding Interview Problems
Master DSA in the AI era by trying the coding challenges below.
- 1.Count occurrencesEasy
- 2.Fix the default listEasy
- 3.Move zeroesEasy
- 4.Is subsequenceEasy
- 5.First unique characterEasy
- 6.Group anagramsMedium
- 7.Climb stairsEasy
