3
bool arrayStringsAreEqual(vector<string> &word1, vector<string> &word2) {4
int wordIdx1 = 0, wordIdx2 = 0, chIdx1 = 0, chIdx2 = 0;6
char ch1 = word1[wordIdx1][chIdx1];7
char ch2 = word2[wordIdx2][chIdx2];8
if (ch1 != ch2) return false;10
chIdx1++; // incrementing the character index of current word from "word1"11
chIdx2++; // incrementing the character index of current word from13
//=========================================================14
if (chIdx1 == word1[wordIdx1].size()) // if current word from "word1" is over16
wordIdx1++; // move to next word in "word1"17
chIdx1 = 0; // reset character index to 019
if (chIdx2 == word2[wordIdx2].size()) // if current word from "word2" is over21
wordIdx2++; // move to next word in "word2"22
chIdx2 = 0; // reset character index to 024
//=================================================================25
if (wordIdx1 == word1.size() && wordIdx2 == word2.size())26
break; // words in both arrays are finished28
if (wordIdx1 == word1.size() || wordIdx2 == word2.size()) return false;29
// if words in any onr of the arrays are finished and other still has some30
// words in it then there is no way same string could be formed on