← Questions

Maximum sum of a subarray whose ends differ by k

0
GoogleCodingLast asked Apr 2026

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.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding