class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
return "".join(word1) == "".join(word2)Where and are the total number of characters in both the arrays and , respectively.
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
s1 = "".join(word1)
i = 0
for w in word2:
for c in w:
if i == len(s1) or s1[i] != c:
return False
i += 1
return i == len(s1)Where and are the total number of characters in both the arrays and , respectively.
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
w1 = w2 = 0 # Index of word
i = j = 0 # Index of character
while w1 < len(word1) and w2 < len(word2):
if word1[w1][i] != word2[w2][j]:
return False
i, j = i + 1, j + 1
if i == len(word1[w1]):
w1 += 1
i = 0
if j == len(word2[w2]):
w2 += 1
j = 0
return w1 == len(word1) and w2 == len(word2)Where and are the total number of characters in both the arrays and , respectively.