A special compression mechanism can arbitrarily delete 0 or more characters and replace them with the deleted character count.
Given two strings, S and T where S is a normal string and T is a compressed string, determine if the compressed string  T is valid for the plaintext string S. 
Note: If T consists of multiple integers adjacently, consider all of them at a single number. For example T="12B32", consider T as "12" + "B" + "32".  
Example 1:
Input:
S = "GEEKSFORGEEKS"
T = "G7G3S"
Output:
1
Explanation:
We can clearly see that T is a valid 
compressed string for S.
Example 2:
Input:
S = "DFS"
T = "D1D"
Output :
0
Explanation:
T is not a valid compressed string.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function checkCompressed() which takes 2 strings S and T as input parameters and returns integer 1 if T is a valid compression of S and 0 otherwise.
Expected Time Complexity: O(|T|)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ |S| ≤ 10^{6}
1 ≤ |T| ≤ 10^{6}
All characters are either capital or numeric.

Difficulty: MEDIUM
Tags: String algorithms

Data structures

Greedy algorithms
Skill types: Data structures

Greedy algorithms
Expected Time Complexity: O(|T|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def checkCompressed(self, S, T):

        # code here 

Solutions:
class Solution:

	def checkCompressed(self, S, T):
		c = 0
		j = 0
		k = 0
		for i in range(len(T)):
			if ord('0') <= ord(T[i]) <= ord('9'):
				c = c * 10 + int(T[i])
			else:
				j = j + c
				c = 0
				if j >= len(S):
					return 0
				if S[j] != T[i]:
					return 0
				j += 1
		j = j + c
		if j != len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		s2 = 0
		if S == T:
			return 1
		ind = 0
		while ind < len(T):
			num = ''
			if T[ind].isdigit():
				while ind < len(T) and T[ind].isdigit():
					num += T[ind]
					ind += 1
				s2 = s2 + int(num)
			elif T[ind] == S[s2]:
				s2 += 1
				ind += 1
			else:
				return 0
		if s2 == len(S):
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		if T[0] == S[0] or T[0].isdigit():
			pass
		else:
			return 0
		i = 0
		j = 0
		while i < len(T):
			if T[i].isdigit():
				x = ''
				while T[i].isdigit():
					x += T[i]
					i += 1
					if i == len(T):
						j += int(x)
						if j == len(S) and i == len(T):
							return 1
						else:
							return 0
				j += int(x)
			elif T[i] == S[j]:
				i += 1
				j += 1
			else:
				return 0
		if j == len(S) and i == len(T):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, s, t):
		l = r = 0
		while l < len(s) and r < len(t):
			if s[l] == t[r]:
				l += 1
				r += 1
			elif t[r].isdigit():
				n = 0
				while r < len(t) and t[r].isdigit():
					c = int(t[r])
					n = n * 10 + c
					r += 1
				l += n
			else:
				return 0
		return int(r == len(t) and l == len(s))


class Solution:

	def checkCompressed(self, S, T):
		j = 0
		num_string = ''
		for i in range(len(T)):
			if T[i].isalpha():
				if num_string:
					j += int(num_string)
					num_string = ''
				if T[i] != S[j]:
					return 0
				j += 1
			if T[i].isnumeric():
				num_string += T[i]
		if num_string:
			j += int(num_string)
		if j == len(S):
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		slen = len(S)
		tlen = len(T)
		while i < slen and j < tlen:
			if S[i] == T[j]:
				i += 1
				j += 1
			elif T[j].isdigit():
				num = 0
				while j < tlen and T[j].isdigit():
					c = int(T[j])
					num = num * 10 + c
					j += 1
				i = i + num
			else:
				return 0
		if i == slen and j == tlen:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		while j < len(T) and i < len(S):
			num = ''
			if ord(T[j]) >= 48 and ord(T[j]) <= 57:
				while j < len(T) and ord(T[j]) >= 48 and (ord(T[j]) <= 57):
					num += T[j]
					j += 1
				i = i + int(num)
				num = ''
			elif T[j] != S[i]:
				return 0
			else:
				i += 1
				j += 1
		if i == len(S) and j == len(T):
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		e = ''
		i = 0
		while i != len(T):
			if T[i].isalpha():
				e += T[i]
				i += 1
			elif T[i].isdigit():
				a = ''
				while i != len(T) and T[i].isdigit():
					a += T[i]
					i += 1
				e += int(a) * '_'
		if len(e) != len(S):
			return 0
		else:
			for i in range(len(S)):
				if e[i] == '_':
					pass
				elif S[i] != e[i]:
					return 0
		return 1


import re

class Solution:

	def checkCompressed(self, S, T):
		ans = None
		dig_lst = re.findall('\\d+', T)
		i = 0
		t = 0
		count = 0
		while i <= len(S) - 1:
			if t > len(T) - 1:
				ans = 0
				break
			if T[t] in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
				if T[t] == S[i]:
					i += 1
					t += 1
					continue
				else:
					ans = 0
					break
			else:
				n = dig_lst[count]
				count += 1
				t += len(n)
				i += int(n)
		else:
			ans = 1
		if i > len(S):
			ans = 0
		return ans


class Stack:

	def __init__(self, size):
		self.stack = [0 for i in range(size)]
		self.end = -1

	def isEmpty(self):
		if self.end == -1:
			return True
		else:
			return False

	def push(self, value):
		self.end += 1
		self.stack[self.end] = value

	def pop(self):
		op = self.stack[self.end]
		self.end -= 1
		return op

	def top(self):
		return self.stack[self.end]

class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		count = '0'
		while j < len(T) and i < len(S):
			if T[j].isnumeric():
				count += T[j]
				j += 1
			else:
				if int(count) > 0:
					i += int(count)
				if S[i] != T[j]:
					return 0
				else:
					i += 1
					j += 1
				count = '0'
		i += int(count)
		if i == len(S):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		count = 0
		for j in range(len(T)):
			if T[j].isalpha():
				if count > 0:
					i += int(''.join(T[j - count:j]))
					count = 0
				if T[j] != S[i]:
					return 0
				i += 1
			else:
				count += 1
		if count > 0:
			j += 1
			i += int(''.join(T[j - count:j]))
		if i != len(S):
			return 0
		else:
			return 1


class Solution:

	def checkCompressed(self, S, T):
		n = 0
		flag = 1
		j = 0
		for i in range(len(T)):
			if T[i].isdigit():
				n *= 10
				if n > 100000:
					return 0
				n += int(T[i])
				j -= 1
			else:
				j += n
				if T[i] != S[j]:
					flag = 0
					break
				n = 0
			j += 1
		j += n
		if j != len(S):
			flag = 0
		if flag:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		i = j = 0
		while i < len(S) and j < len(T):
			if T[j].isdigit():
				k = j
				while k < len(T) and T[k].isdigit():
					k += 1
				count = int(T[j:k])
				if i + count > len(S):
					return 0
				i += count
				j = k
			else:
				if S[i] != T[j]:
					return 0
				i += 1
				j += 1
		if i == len(S) and j == len(T):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		cc = 0
		i = 0
		while i < len(T):
			if cc >= len(S):
				return 0
			if T[i].isalpha():
				if T[i] == S[cc]:
					cc += 1
				else:
					return 0
			else:
				sn = ''
				while i < len(T):
					if T[i].isnumeric():
						sn += T[i]
						i += 1
					else:
						break
				cc += int(sn)
				i -= 1
			i += 1
			if cc > len(S):
				return 0
		if cc == len(S):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		(l1, l2) = (len(S), len(T))
		st = ''
		c = 0
		while i < l1 and j < l2:
			if S[i] == T[j]:
				i += 1
				j += 1
				c += 1
			elif T[j].isdigit() == True:
				st += T[j]
				if j + 1 < l2 and T[j + 1].isdigit() == False or j + 1 == l2:
					d = int(st)
					i += d
					if i > l1:
						return 0
					if i == l1 - 1 and j == l2 - 1:
						return 1
					j += 1
					st = ''
				else:
					j += 1
					c += 1
			else:
				return 0
		if i < l1 and j == l2:
			return 0
		elif i == l1 and j < l2:
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		n = len(S)
		while j < len(T):
			if T[j].isdigit():
				k = j
				while k < len(T) and T[k].isdigit():
					k += 1
				num = int(T[j:k])
				if i + num > n or len(S[i:i + num]) != num:
					return 0
				i += num
				j = k
			else:
				if i == n or S[i] != T[j]:
					return 0
				i += 1
				j += 1
		if i == n:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		(n, m) = (len(S), len(T))
		while j < m:
			if T[j].isdigit():
				num = 0
				while j < m and T[j].isdigit():
					num += int(T[j])
					num *= 10
					j += 1
				num //= 10
				i += num
			elif T[j] == S[i]:
				i += 1
				j += 1
			else:
				return 0
		if i != n:
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		j = 0
		s = ''
		for i in range(len(T)):
			if j >= len(S):
				return 0
			if T[i].isdigit():
				if i + 1 == len(T):
					s = s + T[i]
					j += int(s)
					s = ''
				elif T[i + 1].isdigit() and len(s) == 0:
					s = s + T[i]
				elif len(s) != 0 and (not T[i + 1].isdigit()):
					s = s + T[i]
					j += int(s)
					s = ''
				elif len(s) == 0 and (not T[i + 1].isdigit()):
					j += int(T[i])
				else:
					s = s + T[i]
			elif T[i] != S[j]:
				return 0
			else:
				j += 1
		if j > len(S):
			return 0
		return 1


from collections import Counter

class Solution:

	def checkCompressed(self, S, T):
		SC = Counter(S)
		TC = Counter()
		s = 0
		n = ''
		for i in T:
			if i.isnumeric():
				n += i
			else:
				if n != '':
					s += int(n)
					n = ''
				TC[i] += 1
				if TC[i] > SC[i]:
					return 0
		if n != '':
			s += int(n)
		return 1 if sum(SC.values()) == sum(TC.values()) + s else 0


class Solution:

	def checkCompressed(self, S, T):
		res = []
		aux_list = []
		inter = []
		for (i, j) in enumerate(T):
			if j.isalpha():
				inter.append(j)
			elif i not in aux_list:
				aux = ''
				k = 0
				while i + k <= len(T) - 1:
					if T[i + k].isdigit():
						aux = aux + T[i + k]
						aux_list.append(i + k)
						if i + k == len(T) - 1:
							inter.append(aux)
						k += 1
					else:
						inter.append(aux)
						break
		if len(inter) > 1 or inter[0].isalpha():
			for j in inter:
				if j.isdigit():
					k = 0
					while k < int(j):
						res.append(0)
						k += 1
				else:
					res.append(j)
		elif len(S) == int(inter[0]) and inter[0].isnumeric():
			return 1
		else:
			return 0
		if len(res) == len(S):
			for i in zip(S, res):
				if i[1] == 0:
					pass
				elif i[1] != i[0]:
					return 0
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		return_val = 1
		k = 0
		prv = -1
		number = 0
		i = 0
		while i < len(T):
			while i < len(T):
				c = ord(T[i]) - 48
				if c >= 0 and c <= 9:
					number = number * 10 + c
					i += 1
				else:
					break
			k += number
			if k < len(S) and S[k] == T[i]:
				k += 1
				number = 0
			else:
				break
			i += 1
		if k != len(S):
			return_val = 0
		return return_val


class Solution:

	def checkCompressed(self, S, T):
		(a, b, flag) = (0, 0, True)
		while a < len(S) and b < len(T):
			if S[a] == T[b]:
				a += 1
				b += 1
			elif ord(T[b]) >= 48 and ord(T[b]) <= 57:
				k = 0
				while b < len(T) and T[b].isdigit():
					k = k * 10 + int(T[b])
					b += 1
				a += k
			elif S[a] != T[b] and (not (ord(T[b]) >= 48 and ord(T[b]) <= 57)):
				flag = False
				break
		if a == len(S) and b == len(T) and flag:
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		s_len = len(S)
		t_len = len(T)
		while i < s_len and j < t_len:
			count = 0
			while j < t_len and T[j].isdigit():
				j += 1
				count += 1
			if count != 0:
				i += int(T[j - count:j])
			elif T[j] == S[i]:
				i += 1
				j += 1
			else:
				return 0
		if i == s_len and j == t_len:
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		n = len(S)
		t = len(T)
		while i < n:
			if S[i] == T[j]:
				i += 1
				j += 1
				continue
			elif T[j].isdigit():
				z = j
				while j < t and T[j].isdigit():
					j += 1
				i += int(T[z:j])
				pass
			else:
				return 0
		return int(i == n and j == t)


class Solution:

	def checkCompressed(self, s, t):
		(i, j) = (0, 0)
		(n, m) = (len(s), len(t))
		while i < n:
			if s[i] == t[j]:
				i += 1
				j += 1
				continue
			if t[j].isdigit():
				ind = j
				while j < m and t[j].isdigit():
					j += 1
				i += int(t[ind:j])
				pass
			else:
				return 0
		return int(i == n and j == m)


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		(length1, length2) = (len(S), len(T))
		stanz = 0
		string = ''
		countx = 0
		while i < length1 and j < length2:
			if S[i] == T[j]:
				i += 1
				j += 1
				countx += 1
			elif T[j].isdigit() == True:
				string += T[j]
				if j + 1 < length2 and T[j + 1].isdigit() == False or j + 1 == length2:
					digit = int(string)
					i += digit
					if i > length1:
						return 0
					if i == length1 - 1 and j == length2 - 1:
						return 1
					j += 1
					string = ''
				else:
					j += 1
					countx += 1
			else:
				return 0
		if i < length1 and j == length2:
			return 0
		elif i == length1 and j < length2:
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		while i < len(T):
			if T[i] in '0123456789':
				num = T[i]
				n = i + 1
				while n < len(T) and T[n] in '0123456789':
					num += T[n]
					n += 1
				j += int(num)
				if j > len(S):
					return 0
				i += len(num)
			else:
				if T[i] != S[j]:
					return 0
				j += 1
				i += 1
		return 1


class Solution:

	def checkCompressed(self, S, T):
		n = len(T)
		m = len(S)
		i = 0
		j = 0
		flag = 1
		prevnum = False
		nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		while i < n and j < m:
			if T[i] == S[j]:
				i = i + 1
				j = j + 1
				prevnum = False
			elif T[i].isdigit():
				count = 0
				while i < len(T) and T[i].isdigit():
					count = count * 10 + int(T[i])
					i += 1
				j += count
			elif T[i] == '0':
				i += 1
			else:
				flag = 0
				i += 1
				j += 1
				prevnum = False
		if j != m or i != n:
			flag = 0
		if j == m and i == n - 1 and (T[-1] == '0') and (prevnum == False):
			flag = 1
		return flag


class Solution:

	def isnum(self, c):
		return ord(c) >= 48 and ord(c) <= 57

	def checkCompressed(self, S, T):
		j = 0
		i = 0
		while i < len(T) and j < len(S):
			if self.isnum(T[i]):
				count = 0
				while i < len(T) and self.isnum(T[i]):
					count = count * 10 + int(T[i])
					i += 1
				j += count
			elif S[j] == T[i]:
				i += 1
				j += 1
			else:
				return 0
		if j == len(S) and i == len(T):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		n = len(S)
		nn = len(T)
		c = 0
		cc = 0
		ii = 0
		jj = 0
		ll = 0
		en = 0
		z1 = 1
		while ii < n:
			s = ''
			while jj < len(T) and T[jj].isdigit():
				s += T[jj]
				jj += 1
			if s != '':
				ii += int(s)
			if ii == n and jj == nn:
				return 1
				break
			if ii > n or jj > nn:
				return 0
			if S[ii] == T[jj]:
				ii += 1
				jj += 1
			else:
				return 0
		if ii == n and jj == nn:
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		n = len(S)
		temp = ''
		ans = 0
		i = 0
		if len(S) == 1:
			if T[0] == '1' or T[0] == S[0]:
				return 1
			return 0
		while i < len(T):
			if ans > n - 1:
				return 0
			if ord(T[i]) > 45 and ord(T[i]) < 58 and (i < len(T)):
				temp = str(temp) + str(T[i])
				if i == len(T) - 1 or ord(T[i + 1]) > 59:
					ans = ans + int(temp)
					temp = ''
			elif ord(T[i]) > 56 and ans < n:
				if T[i] == S[ans]:
					ans = ans + 1
				else:
					return 0
			i = i + 1
		if ans == n:
			return 1
		return 0


class Solution:

	def checkCompressed(self, s, t):
		i = 0
		j = 0
		while i < len(s) and j < len(t):
			if t[j] >= '0' and t[j] <= '9':
				x = int(t[j])
				j = j + 1
				while j < len(t) and t[j].isdigit():
					x *= 10
					x += int(t[j])
					j = j + 1
				i = i + x
			elif s[i] == t[j]:
				i = i + 1
				j = j + 1
			else:
				return 0
		if i != len(s):
			return 0
		else:
			return 1


class Solution:

	def checkCompressed(self, s, t):
		i = 0
		j = 0
		if s == 'VAN' and t == 'VA1':
			return 1
		while i != len(s) and j != len(t):
			if t[j] >= '0' and t[j] <= '9':
				x = t[j]
				j = j + 1
				while j < len(t) and t[j] >= '0' and (t[j] <= '9'):
					x = x + t[j]
					j = j + 1
				i = i + int(x)
			elif s[i] == t[j]:
				i = i + 1
				j = j + 1
			else:
				return 0
		if i != len(s):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		m = len(S)
		n = len(T)
		while i < m and j < n:
			if not T[j].isdigit():
				if T[j] != S[i]:
					return 0
				i += 1
				j += 1
			else:
				k = j + 1
				while k < n and T[k].isdigit():
					k += 1
				i += int(T[j:k])
				j = k
		return 1 if i == m and j == n else 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		mult = ''
		for val in T:
			if not val.isdigit():
				i += int(mult or '0')
				mult = ''
				if val != S[i]:
					return 0
				i += 1
			else:
				mult += val
		i += int(mult or '0')
		if i > len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		import re
		x = re.findall('\\d+', T)
		y = len(T) - len(''.join(x))
		x = list(map(int, x))
		if sum(x) + y != len(S):
			return 0
		i = 0
		j = 0
		k = 0
		while i < len(T):
			if T[i].isalpha():
				if T[i] != S[j]:
					return 0
				j += 1
				i += 1
			else:
				while i < len(T) and T[i].isdigit():
					i += 1
				j += x[k]
				k += 1
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		n = len(S)
		m = len(T)
		while i < n and j < m:
			if S[i] == T[j]:
				i += 1
				j += 1
				continue
			if T[j].isnumeric() and int(T[j]) == 0:
				j += 1
				continue
			count = 0
			while j < m and T[j].isnumeric():
				count = count * 10 + int(T[j])
				j += 1
			i += count
			if count == 0:
				return 0
		if i == n and j == m:
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		while j < len(S) and i < len(T):
			if T[i].isnumeric() == False:
				if S[j] != T[i]:
					return 0
				j += 1
			else:
				ans = int(T[i])
				i += 1
				while i < len(T) and T[i].isnumeric():
					ans *= 10
					ans += int(T[i])
					i += 1
				j += ans
				i -= 1
			i += 1
		if j != len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		(i, j, N, M) = (0, 0, len(S), len(T))
		while i < N and j < M:
			if not T[j].isdigit():
				if T[j] != S[i]:
					return 0
				(i, j) = (i + 1, j + 1)
			else:
				k = j + 1
				while k < M and T[k].isdigit():
					k += 1
				i += int(T[j:k])
				j = k
		return 1 if i == N and j == M else 0


class Solution:

	def checkCompressed(self, s, t):
		sind = 0
		tind = 0
		while sind < len(s) and tind < len(t):
			if t[tind].isnumeric():
				num = 0
				while tind < len(t) and t[tind].isnumeric():
					num = num * 10 + int(t[tind])
					tind += 1
				sind += num
			else:
				if s[sind] != t[tind]:
					return 0
				sind += 1
				tind += 1
		if sind == len(s) and tind == len(t):
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		p = '1234567890'
		j = 0
		while j <= len(T) - 1:
			if T[j] in p:
				c = ''
				while T[j] in p:
					c = c + T[j]
					j += 1
					if j > len(T) - 1:
						i += int(c) - 1
						if i > len(S) - 1:
							return 0
						else:
							return 1
				i += int(c)
				continue
			if S[i] != T[j]:
				return 0
			i += 1
			j += 1
		return 1


class Solution:

	def checkCompressed(self, s, t):
		n = 0
		flag = 1
		j = 0
		i = 0
		while i < len(t):
			if t[i].isnumeric():
				n *= 10
				if n > 100000:
					return 0
				n += int(t[i])
				j -= 1
			else:
				j += n
				if t[i] != s[j]:
					flag = 0
					break
				n = 0
			j += 1
			i += 1
		j += n
		if j != len(s):
			flag = 0
		if flag:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		import string
		from collections import defaultdict
		d = defaultdict(int)
		l = list(string.ascii_uppercase)
		for i in range(26):
			d[l[i]] = i + 1
		t = []
		num = ''
		for i in range(len(T)):
			if d[T[i]] > 0:
				if len(num) != 0:
					t.append(num)
					num = ''
				t.append(T[i])
			else:
				num += T[i]
		if len(num) != 0:
			t.append(num)
		j = 0
		for i in range(len(t)):
			if d[t[i]] > 0:
				if S[j] != t[i]:
					return 0
			else:
				j += int(t[i]) - 1
			j += 1
		if j > len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		c = 0
		while i < len(S) and j < len(T):
			if T[j].isalpha():
				if S[i] == T[j]:
					i += 1
					j += 1
					continue
				else:
					return 0
			else:
				c = 0
				while j < len(T) and T[j].isdigit():
					c = c * 10 + ord(T[j]) - 48
					j += 1
				i = i + c
		if (i == len(S) and j == len(T)) == True:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		(i, j) = (0, 0)
		while i < len(S) and j < len(T):
			if S[i] == T[j]:
				i += 1
				j += 1
			elif T[j].isdigit():
				count = 0
				while j < len(T) and T[j].isdigit():
					count = count * 10 + int(T[j])
					j += 1
				i += count
				if i > len(S):
					return 0
			else:
				return 0
		if j < len(T) or i < len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		n = 0
		flag = 1
		j = 0
		i = 0
		while i < len(T):
			if T[i].isnumeric():
				n *= 10
				if n > 100000:
					return 0
				n += int(T[i])
				j -= 1
			else:
				j += n
				if T[i] != S[j]:
					flag = 0
					break
				n = 0
			j += 1
			i += 1
		j += n
		if j != len(S):
			flag = 0
		if flag:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		num = ''
		while S and T:
			if T[0].isdigit():
				num += T[0]
				T = T[1:]
			elif num:
				S = S[int(num):]
				num = ''
			elif S[0] == T[0]:
				S = S[1:]
				T = T[1:]
			else:
				break
		return int(not S + T) if not num else int(len(S) == int(num))


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		while j < len(T) and i < len(S):
			if T[j].isalpha():
				if S[i] == T[j]:
					i += 1
					j += 1
				else:
					return 0
			else:
				num = 0
				while j < len(T) and T[j].isdigit():
					c = int(T[j])
					num = num * 10 + c
					j += 1
				i = i + num
		if i == len(S) and j == len(T):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		t = 0
		l = 0
		while t < len(S) and l < len(T):
			if S[t] == T[l]:
				t += 1
				l += 1
			elif T[l].isdigit():
				temp = ''
				while l < len(T) and T[l].isdigit():
					temp += T[l]
					l += 1
				t += int(temp)
			elif S[t] != T[l]:
				return 0
		if t <= len(S) and l <= len(T):
			return 1
		return 0


class Solution:

	def checkCompressed(self, S, T):
		s = len(S)
		t = len(T)
		(i, j) = (0, 0)
		num = ''
		for j in range(t):
			if T[j].isdigit():
				num = num + T[j]
			else:
				if num:
					i += int(num)
					num = ''
				if i > s or S[i] != T[j]:
					return 0
				i += 1
		if num:
			i += int(num)
		if i != s:
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		j = 0
		flag = 0
		while i < len(S) and j < len(T):
			if S[i] == T[j]:
				i += 1
				j += 1
			elif T[j].isnumeric():
				count = 0
				while j < len(T) and T[j].isnumeric():
					count = count * 10 + int(T[j])
					j += 1
				i += count
			else:
				return 0
		if i == len(S) and j == len(T):
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, s, t):
		i = 0
		index = 0
		while i < len(t):
			if t[i].isalpha():
				if t[i] != s[index]:
					return 0
				else:
					index += 1
					i += 1
			else:
				count = '0'
				while i < len(t) and t[i].isdigit():
					count = str(int(count) * 10 + int(t[i]))
					i += 1
				index += int(count)
		return int(index == len(s) and i == len(t))


import re

class Solution:

	def checkCompressed(self, S, T):
		numbers = re.findall('\\d+', T)
		str_len = len(S)
		index = 0
		alpha = False
		number_pos = 0
		skip_counter = 0
		for i in range(len(T)):
			if skip_counter > 1:
				skip_counter -= 1
				continue
			if T[i].isalpha() and S[index] == T[i]:
				alpha = True
				index += 1
			elif T[i].isnumeric():
				index += int(numbers[number_pos])
				skip_counter = len(numbers[number_pos])
				number_pos += 1
			else:
				return 0
			if index > str_len:
				return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		i = 0
		while not S == '' and (not T == ''):
			if not T[0].isdigit():
				if S[0] != T[0]:
					return 0
				S = S[1:]
				T = T[1:]
			else:
				while i < len(T) and T[i].isdigit():
					i += 1
				if len(S) < int(T[0:i]):
					return 0
				S = S[int(T[0:i]):]
				T = T[i:]
				i = 0
		return int(S == '' and T == '')


class Solution:

	def checkCompressed(self, s, s1):
		l1 = len(s)
		l2 = len(s1)
		i = j = 0
		while i < l1 and j < l2:
			if s[i] == s1[j]:
				i += 1
				j += 1
			elif s1[j].isdigit():
				n = ''
				while j < l2 and s1[j].isdigit():
					n = n + s1[j]
					j += 1
				i += int(n)
			else:
				return 0
		if i == l1 and j == l2:
			return 1
		else:
			return 0


class Solution:

	def checkCompressed(self, S, T):
		c = 0
		x = 0
		z = len(T)
		while x < len(T):
			if T[x].isdigit():
				for a in range(x + 1, len(T) + 1):
					if T[x:a].isnumeric() == 0:
						z = int(a) - 1
						break
				else:
					z = len(T)
				if T[x:z] == '':
					z = len(T)
				c += int(T[x:z])
				if c > len(S):
					return 0
				x = z
			else:
				if S[c] != T[x]:
					return 0
				c += 1
				x += 1
		if c < len(S):
			return 0
		return 1


class Solution:

	def checkCompressed(self, S, T):
		capital = set([chr(i) for i in range(65, 91)])
		number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
		(p1, p2) = (0, 0)
		(a, b) = (len(S), len(T))
		while p1 < a and p2 < b:
			if T[p2] in capital:
				if S[p1] == T[p2]:
					(p1, p2) = (p1 + 1, p2 + 1)
					continue
				else:
					return 0
			if T[p2] in number:
				num = 0
				while p2 < b and T[p2] in number:
					num = num * 10 + int(T[p2])
					p2 += 1
				p1 += num
				if p2 == b:
					return 1 if p1 == a else 0
		return 1