class Solution {
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
int i = 0, p = 0;
int j = 0, q = 0;
while (i < word1.length && j < word2.length) {
if (word1[i].charAt(p++) != word2[j].charAt(q++)) return false;
if (p == word1[i].length()) { i++; p = 0; }
if (q == word2[j].length()) { j++; q = 0; }
}
return i == word1.length && j == word2.length;
}
}
class Solution {
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
String ans1 = null, ans2 = null;
for (String word: word1) ans1 += word;
for (String word: word2) ans2 += word;
return ans1.equals(ans2);
}
}