Problem solving with programming: Maximum length of subarray with non-zero elements
Given an array of of size N, How do we find the longest sub-array with all non-zero elements?
Read full article from Problem solving with programming: Maximum length of subarray with non-zero elementsmax_len = 0current_len = 0index = 0while index < n:if num_list[index] == 0:max_len = max(max_len,current_len)current_len = 0else:current_len += 1index += 1max_len = max( max_len, current_len)