Tencent Interview Question

Leetcode 192 counting the words