Pocket Gems interview question

1. finding substring, k most frequent items