Implement greedy decoding and beam search | Microsoft Interview Question