def max_length(s, k):
    current = []
max_len = -1
for i in s:
    current.append(i)
while sum(current) > k:
    current = current[1:]
if sum(current) == k:
    max_len = max(max_len, len(current))
return max_len
Length of longest subarray of sum less than or equal to k