696. Count Binary Substrings


https://leetcode.com/problems/count-binary-substrings


Time Limit Exceeded


```python
import re 

class Solution:
    def countBinarySubstrings(self, s: str) -> int:
        #3:31
        max_repeated_times = min(s.count("1"), s.count("0"))
        counting = 0
        for i in range(1, max_repeated_times+1):
            #re.findall("(1{1,1}0{1,1})|(0{1,1}1{1,1})", s)
            s_i = str(i)
            part = s_i+","+s_i
            regex1 = "1{"+part+"}0{"+part+"}"
            results1 = re.findall(regex1, s)
            regex2 = "0{"+part+"}1{"+part+"}"
            results2 = re.findall(regex2, s)
            #print(results1)
            #print(results2)
            if (len(results1) == 0 and len(results2) == 0):
                break
            else:
                counting += len(results1) + len(results2)
        return counting
        #4:22
```
