Describe how you would solve a problem using a sliding window approach.
Implement longest_subarray(nums, target) for a list of non-negative integers. Return the maximum length of a contiguous subarray whose sum is at most target, or 0 if no non-empty subarray qualifies.
Examples: nums = [2, 1, 5, 1, 3, 2], target = 7 returns 3; nums = [3, 1, 1, 1, 3], target = 5 returns 3 because no qualifying window has length four. Use a single pass with O(1) auxiliary space.
def longest_subarray(nums, target):