Given an integer array nums and an integer target, return the length of the longest continuous subarray whose elements sum to target. If no such subarray exists, return 0. The array may contain positive numbers, negative numbers, and zeros.
def longest_subarray_with_sum(nums, target):