Build next-word predictor with O(1) lookup | Google Interview Question