Amazon interview question

Question about array traversal using heap and finding substring