1662. Check If Two String Arrays are Equivalent
Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.
A string is represented by an array if the array elements concatenated in order forms the string.
1 2 3 4 5 6 7 8 9 10 11 12 13
| class Solution { public: bool arrayStringsAreEqual(vector<string>& A, vector<string>& B) { while(A.size() and B.size()) { if(A.back().back() != B.back().back()) return false; A.back().pop_back(); B.back().pop_back(); if(A.back().empty()) A.pop_back(); if(B.back().empty()) B.pop_back(); } return A.empty() and B.empty(); } };
|