代码1:
class Solution {
public:
bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
string s1, s2;
for (string s : word1) s1 += s;
for (string s : word2) s2 += s;
return s1 == s2;
}
};
代码2:
class Solution {
public:
bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
//字符串拼接
string s1,s2;
for(int i = 0;i<word1.size();i++)
s1 +=word1[i];
for(int i = 0;i<word2.size();i++)
s2 +=word2[i];
if(s1 == s2) return true;
else return false;
}
};