defzero_sum(a):""" Space complexity: O(N) Computational complexity: O(N) """ max_length =0 sub_arr_sum =0 hash_map ={}# index of the last position of the sum# key = sumfor i inrange(len(a)): sub_arr_sum += a[i]if a[i]==0and max_length ==0: max_length =1if sub_arr_sum ==0: max_length = i +1if sub_arr_sum in hash_map:# when you see a repeated sum, you can assume the # delta between both positions sums zero. max_length =max(max_length, i - hash_map[sub_arr_sum])else: hash_map[sub_arr_sum]= ireturn max_length