Zig and Zag are playing a word game. Zig says one letter, and Zag says a word that starts
with that letter. However, the word needs to be from the allowed word list and such that Zag
already said it the least amount of times. If the word choice is ambiguous, then Zag will
choose the one that is lexicographically smaller (sooner in the alphabet). For each Zig’s
letter, it will be possible to choose a word.
Let there be a list consisting of exactly K distinct words and an array of N letters that Zig has
given. Write a program that will, based on the input, output an array of N words that Zag said
during the game.