Maximum Size Subarray Sum Equals k — prefix sums
If two prefix sums differ by exactly k, the stretch between them sums to k. Remember the earliest index of each prefix sum, so any later match gives the longest possible subarray.
Try:
nums
running sum 0
longest subarray with sum k 0
prefix sum → first index