Given a string s, the power of the string is the maximum length of a non-empty substring that contains only one unique character.
Return the power of the string.
 
Example 1:
Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.

Example 2:
Input: s = "abbcccddddeeeeedcba"
Output: 5
Explanation: The substring "eeeee" is of length 5 with the character 'e' only.

Example 3:
Input: s = "triplepillooooow"
Output: 5

Example 4:
Input: s = "hooraaaaaaaaaaay"
Output: 11

Example 5:
Input: s = "tourist"
Output: 1

 
Constraints:

1 <= s.length <= 500
s contains only lowercase English letters.

Difficulty: EASY
Tags: String algorithms

Starter code:
class Solution:
    def maxPower(self, s: str) -> int:
        

Solutions:
class Solution:

	def maxPower(self, s: str) -> int:
		n = len(s)
		count = 0
		res = s[0]
		cur_count = 1
		for i in range(n):
			if i < n - 1 and s[i] == s[i + 1]:
				cur_count += 1
			else:
				if cur_count > count:
					count = cur_count
					res = s[i]
				cur_count = 1
		return count


class Solution:

	def maxPower(self, s: str) -> int:
		cnt = 0
		current = s[0]
		current_cnt = 1
		for l in s[1:]:
			if l == current:
				current_cnt += 1
			else:
				if current_cnt > cnt:
					cnt = current_cnt
				current = l
				current_cnt = 1
		if current_cnt > cnt:
			cnt = current_cnt
		return cnt


class Solution:

	def maxPower(self, s: str) -> int:
		count = 0
		new_count = 0
		for (i, char) in enumerate(s):
			print(char)
			try:
				if s[i + 1] == char:
					new_count += 1
				else:
					print('afwww')
					if new_count >= count:
						count = new_count
					new_count = 0
			except:
				print('sefesf')
				if new_count >= count:
					print('sfwafawfawfawfawfawf')
					count = new_count
					new_count = 0
				break
		return count + 1


class Solution:

	def maxPower(self, s: str) -> int:
		c = {'power': 1}
		for i in range(len(s)):
			if i == len(s) - 1:
				break
			if ord(s[i]) == ord(s[i + 1]):
				c['power'] += 1
			else:
				c['new start#%s' % i] = c['power']
				c['power'] = 1
		return max(c.values())


class Solution:

	def maxPower(self, s: str) -> int:
		power = 1
		max_power = 0
		for (idx, i) in enumerate(s):
			if len(s) < 2:
				return len(s)
			if idx == 0:
				pass
			elif i == s[idx - 1]:
				power += 1
				print(f' i is {i}, power is {power}')
			else:
				print(f' i is {i}, power is {power}')
				if power > max_power:
					max_power = power
				power = 1
		return max(power, max_power)


class Solution:

	def maxPower(self, s: str) -> int:
		letter = None
		length = 0
		max_length = 0
		for i in s:
			if i == letter:
				length += 1
				max_length = max(max_length, length)
			else:
				max_length = max(max_length, length, 1)
				length = 1
				letter = i
			print(i, max_length)
		return max_length


class Solution:

	def maxPower(self, s: str) -> int:
		z = []
		c = 0
		if len(s) == 1:
			return 1
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				c = c + 1
			else:
				z.append(c)
				c = 0
		z.append(c)
		return max(z) + 1


class Solution:

	def maxPower(self, s: str) -> int:
		if len(s) <= 1:
			return len(s)
		last_char = s[0]
		count = 1
		max_count = 0
		for c in s[1:]:
			if c == last_char:
				count += 1
			else:
				if count > max_count:
					max_count = count
				count = 1
			last_char = c
		if count > max_count:
			max_count = count
		return max_count


class Solution:

	def maxPower(self, s: str) -> int:
		prev = None
		count = 0
		max_count = 0
		for char in s:
			if char == prev:
				count += 1
			else:
				prev = char
				count = 1
			max_count = max(max_count, count)
		return max_count


class Solution:

	def maxPower(self, s: str) -> int:
		seq = 1
		max_seq = 1
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				seq += 1
			else:
				max_seq = max(max_seq, seq)
				seq = 1
		max_seq = max(max_seq, seq)
		return max_seq


class Solution:

	def maxPower(self, s: str) -> int:
		count = 0
		max_count = 0
		previous = None
		for c in s:
			if c != previous:
				previous = c
				count = 1
			else:
				count += 1
			max_count = max(max_count, count)
		return max_count


class Solution:

	def maxPower(self, s: str) -> int:
		ans = 0
		consec_count_per_letter = 1
		prev_letter = s[0]
		if len(s) == 1:
			return 1
		for i in range(1, len(s)):
			if s[i] == prev_letter:
				consec_count_per_letter += 1
			else:
				consec_count_per_letter = 1
			prev_letter = s[i]
			ans = max(ans, consec_count_per_letter)
		return ans


class Solution:

	def maxPower(self, s: str) -> int:
		c = 1
		maxc = c
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				c += 1
				maxc = max(maxc, c)
			else:
				c = 1
		return maxc


class Solution:

	def maxPower(self, s: str) -> int:
		maxcount = 1
		i = 0
		while i < len(s) - 1:
			count = 1
			while i < len(s) - 1 and s[i] == s[i + 1]:
				i = i + 1
				count = count + 1
			if count > maxcount:
				maxcount = count
			if i < len(s) - 1:
				i = i + 1
		return maxcount