Question d’entretien chez Amazon

Question about array traversal using heap and finding substring