How do I find a maximum number of consecutive non-zero values in the array?

Yes, it will. Because the original integers are first converted to 0 and 1 with:

map(lambda x:str(int(x>0)),s)

Example:

s = [1003,702,330,106,0,109]

len(max(''.join(map(lambda x:str(int(x>0)),s)).split('0')))

# --> 4
3 Likes