Sponsored
Use these hints if you're stuck. Try solving on your own first.
It is always optimal to select the greatest element in the array.
Use a heap to query for the maximum in O(log n) time.
Solve with full IDE support and test cases