Maximum sum of a subarray whose ends differ by k

0
Remix

Given an integer array and k, a subarray is good when its first and last elements differ by exactly k. Return the largest sum of a good subarray, or 0 if there is none.

GoogleCodingLast asked Apr 2026
No answer yet. Write the first one; the best answer gets endorsed.