counting 1's between any two 0's
def findMaxConsecutiveOnes(self, nums):
start = 0
res = 0
# deal with start/end case where 1's between any two 0's
nums =  + nums + 
for i, num in enumerate(nums):
if num == 0:
res = max(res, i - start - 1)
start = i
So, at each i that is 1, we consider zeroLeft + zeroRight because for an example like 110111, we are considering len(p(2)) + len(run(3)) (run(3) as 3 consecutive 1s).
The code's logic:
For each index i:
if nums[i] is 0: calculate the length of the pattern that ends at nums[i] , and put it into zeroLeft. Reset zeroRight because we are no longer in a run;
if nums[i] is 1: increment zeroRight which records run length, and try to update max with (zeroLeft + zeroRight);
Of course, OP wrote his code in another way, but I think that is the logic here. I solved this problem with a similar approach (considering the separating zeroes), but OP's code is way more elegant than mine.
Again, this is only my way of interpreting this program, and it's highly unlikely this is the thinking process of OP himself. The concept of a pattern is coined not necessarily. I do hope this will aid in the process of you finding your own way of interpretation.