首页 > 其他分享 >1662. 检查两个字符串数组是否相等

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

时间:2022-11-01 10:56:34浏览次数:39  
标签:word1 数组 word2 字符串 true 1662

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

给你两个字符串数组 word1 和 word2 。如果两个数组表示的字符串相同,返回 true ;否则,返回 false 。

  • 输入:word1 = ["ab", "c"], word2 = ["a", "bc"]
  • 输出:true
  • 解释:
    word1 表示的字符串为 "ab" + "c" -> "abc"
    word2 表示的字符串为 "a" + "bc" -> "abc"
    两个字符串相同,返回 true
class Solution {
public:
    bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
        string str1="",str2="";
        for(int i=0;i<word1.size();i++) str1+=word1[i];
        for(int i=0;i<word2.size();i++) str2+=word2[i];
        return str1==str2?true:false;
    }
};

标签:word1,数组,word2,字符串,true,1662
From: https://www.cnblogs.com/SkyDusty/p/16846971.html

相关文章