leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1662.cpp (454B)


      1 class Solution {
      2   public:
      3     bool arrayStringsAreEqual(const vector<string> &word1, const vector<string> &word2) const {
      4         int i = 0, j = 0, k = 0, l = 0;
      5         while (i < word1.size() && j < word2.size()) {
      6             if (word1[i][k] != word2[j][l]) return false;
      7             if (++k == word1[i].size()) k = 0, i++;
      8             if (++l == word2[j].size()) l = 0, j++;
      9         }
     10         return i == word1.size() && j == word2.size();
     11     }
     12 };