leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1662.cpp (454B)
0 class Solution { 1 public: 2 bool arrayStringsAreEqual(const vector<string> &word1, const vector<string> &word2) const { 3 int i = 0, j = 0, k = 0, l = 0; 4 while (i < word1.size() && j < word2.size()) { 5 if (word1[i][k] != word2[j][l]) return false; 6 if (++k == word1[i].size()) k = 0, i++; 7 if (++l == word2[j].size()) l = 0, j++; 8 } 9 return i == word1.size() && j == word2.size(); 10 } 11 };