Amazon Interview Question

Question about array traversal using heap and finding substring