diff --git a/LeetCode Solutions/1869. Longer Contiguous Segments of Ones than Zeros/LongerContiguousSegments ofOnesthanZeros.py b/LeetCode Solutions/1869. Longer Contiguous Segments of Ones than Zeros/LongerContiguousSegments ofOnesthanZeros.py new file mode 100644 index 0000000..12b5c01 --- /dev/null +++ b/LeetCode Solutions/1869. Longer Contiguous Segments of Ones than Zeros/LongerContiguousSegments ofOnesthanZeros.py @@ -0,0 +1,22 @@ +class Solution: + def checkZeroOnes(self, s: str) -> bool: + def check(num): + return num=='1' + def big(x,y): + return x>y + oc=0 + zc=0 + o=0 + z=0 + for x in s: + if check(x): + oc+=1 + if big(zc,z):z=zc + zc=0 + else: + zc+=1 + if big(oc,o):o=oc + oc=0 + if big(zc,z):z=zc + if big(oc,o):o=oc + return big(o,z)