Medium
Minimum Number of Changes to Make Binary String Beautiful — Python
Full explanation · Time O(n) · Space O(1)
# Time: O(n)
# Space: O(1)
# greedy
class Solution(object):
def minChanges(self, s):
"""
:type s: str
:rtype: int
"""
return sum(s[i] != s[i+1] for i in xrange(0, len(s), 2))