LeetCode 1662. 检查两个字符串数组是否相等

LeetCode 1662. 检查两个字符串数组是否相等
LeetCode 1662. 检查两个字符串数组是否相等
代码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;
    }
};
上一篇:模拟72 考试总结


下一篇:72. VUE axios 配置信息相关