Your friend is typing his name into a keyboard.  Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.
You examine the typed characters of the keyboard.  Return True if it is possible that it was your friends name, with some characters (possibly none) being long pressed.
 
Example 1:
Input: name = "alex", typed = "aaleex"
Output: true
Explanation: 'a' and 'e' in 'alex' were long pressed.

Example 2:
Input: name = "saeed", typed = "ssaaedd"
Output: false
Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.

Example 3:
Input: name = "leelee", typed = "lleeelee"
Output: true

Example 4:
Input: name = "laiden", typed = "laiden"
Output: true
Explanation: It's not necessary to long press any character.

 
Constraints:

1 <= name.length <= 1000
1 <= typed.length <= 1000
The characters of name and typed are lowercase letters.

Difficulty: EASY
Starter code: class Solution:
    def isLongPressedName(self, name: str, typed: str) -> bool:
        

Solutions:
class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		name = list(name)
		typed = list(typed)
		while name:
			(i, j) = (0, 0)
			n = name[0]
			while name and name[0] == n:
				i += 1
				name.pop(0)
			while typed and typed[0] == n:
				j += 1
				typed.pop(0)
			if j < i:
				return False
		if typed:
			return False
		return True


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		if name == typed:
			return True
		if len(set(name)) != len(set(typed)):
			return False
		if len(typed) <= len(name):
			return False
		i = 0
		j = 0
		while j < len(typed) and i < len(name):
			if name[i] == typed[j]:
				i += 1
				j += 1
			elif typed[j] == typed[j - 1] and j != 0:
				j += 1
			else:
				return False
		if i == len(name):
			i = i - 1
		if j == len(typed):
			j = j - 1
		return name[i] == typed[j]


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		n = 0
		t = 0
		while n < len(name) and t < len(typed):
			if name[n] == typed[t]:
				n += 1
				t += 1
			elif t and typed[t] == typed[t - 1]:
				t += 1
			else:
				return False
		if n != len(name):
			return False
		while t < len(typed):
			if typed[t] == typed[t - 1]:
				t += 1
			else:
				return False
		return True


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		(name_len, typed_len) = (len(name), len(typed))
		if name == typed:
			return True
		elif name_len >= typed_len:
			return False
		(t_left, t_right) = (0, 1)
		(n_left, n_right) = (0, 1)
		while n_left < name_len and t_left < typed_len:
			while n_right < name_len and name[n_left] == name[n_right]:
				n_right += 1
			while t_right < typed_len and typed[t_left] == typed[t_right]:
				t_right += 1
			if name[n_left] != typed[t_left] or n_right - n_left > t_right - t_left:
				return False
			else:
				(n_left, n_right) = (n_right, n_right + 1)
				(t_left, t_right) = (t_right, t_right + 1)
		return n_left == name_len and t_left == typed_len


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		if name == typed:
			return True
		i = j = 0
		while i < len(name) and j < len(typed):
			cnt_i = cnt_j = 0
			while i < len(name) - 1 and name[i] == name[i + 1]:
				i += 1
				cnt_i += 1
			while j < len(typed) - 1 and typed[j] == typed[j + 1]:
				j += 1
				cnt_j += 1
			if cnt_i > cnt_j:
				return False
			if name[i] != typed[j]:
				return False
			i += 1
			j += 1
		if i != len(name) or j != len(typed):
			return False
		return True


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		if len(typed) < len(name):
			return False
		typed_index = 0
		for i in range(len(name)):
			if typed_index >= len(typed):
				return False
			elif name[i] != typed[typed_index]:
				if typed_index == 0 or typed[typed_index - 1] != typed[typed_index]:
					return False
				else:
					letter = typed[typed_index]
					while typed_index < len(typed) and typed[typed_index] == letter:
						typed_index += 1
					if typed_index == len(typed) or typed[typed_index] != name[i]:
						return False
			else:
				pass
			typed_index += 1
		if typed_index < len(typed) and (typed[typed_index - 1] != typed[typed_index] or typed[typed_index:].count(typed[typed_index]) != len(typed) - typed_index):
			return False
		return True


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		if name is None or len(name) == 0:
			return True
		index = 0
		index2 = 0
		while index < len(name) and index2 < len(typed):
			if name[index] == typed[index2]:
				index += 1
				index2 += 1
			elif name[index] != typed[index2] and index > 0 and (name[index - 1] == typed[index2]):
				index2 += 1
			else:
				return False
		while index2 < len(typed):
			if name[len(name) - 1] == typed[index2]:
				index2 += 1
			else:
				return False
		return index == len(name)


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		(l, r) = (0, 0)
		(n, m) = (len(name), len(typed))
		last = None
		while l < n and r < m:
			if name[l] == typed[r]:
				last = name[l]
				l += 1
				r += 1
			elif last and typed[r] == last:
				r += 1
			else:
				return False
		if l == n:
			while r < m:
				if typed[r] == last:
					r += 1
				else:
					return False
			return True
		return False


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		idx = 0
		(name_len, typed_len) = (len(name), len(typed))
		for (i, val) in enumerate(typed):
			if idx < name_len and name[idx] == val:
				idx += 1
			elif i == 0 or typed[i] != typed[i - 1]:
				return False
		return idx == name_len


class Solution:

	def isLongPressedName(self, name: str, typed: str) -> bool:
		t = self.count(name)
		s = self.count(typed)
		if len(t) != len(s):
			return False
		for (tt, ss) in zip(t, s):
			if tt[0] != ss[0]:
				return False
			if tt[1] > ss[1]:
				return False
		return True

	def count(self, s):
		res = []
		prev = None
		cnt = 0
		for c in s:
			if c == prev:
				cnt += 1
			elif cnt > 0:
				res.append((c, cnt))
				cnt = 1
			else:
				cnt = 1
			prev = c
		return res