Your question is Target Sum Subarray. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Saviynt Identity Cloud may process ordered integer deltas representing changes in access assignments. Given an array of integers and a target value, find the longest non-empty contiguous subarray whose elements sum exactly to the target.
Implement longest_subarray_sum(nums, target). The parameter nums is a list of integers, and target is an integer. Return a two-element list [start, end] containing the zero-based inclusive indices of the longest qualifying subarray. Return [] if no non-empty subarray has the target sum. If multiple subarrays have the same maximum length, return the one with the smallest starting index.
Values may be positive, zero, or negative, so a sliding-window technique is not generally valid.
def longest_subarray_sum(nums, target):