219. Word Count in a Story

Easy · Hash Table

Count how many times each word appears in a story (case-insensitive, ignore punctuation). Return an object where keys are words and values are counts.

Examples

Example 1
Input: "the cat sat on the mat"
Output: {the:2,cat:1,sat:1,on:1,mat:1}
Explanation: 'the' appears twice

Constraints