Skip to content

Instantly share code, notes, and snippets.

@seansio1995
Last active April 6, 2018 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seansio1995/2f468475bc16d9f8239c125a7c6fb215 to your computer and use it in GitHub Desktop.
Save seansio1995/2f468475bc16d9f8239c125a7c6fb215 to your computer and use it in GitHub Desktop.
def countBinarySubstrings(self, s):
s = map(len, s.replace('01', '0 1').replace('10', '1 0').split())
return sum(min(a, b) for a, b in zip(s, s[1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment