[Coursera] KeyIndexCounting algorithm