1662. Check If Two String Arrays are Equivalent
给予两个字串阵列判断它们拼接起来之后是否相等。
Example:
Input: word1 = ["ab", "c"], word2 = ["a", "bc"]
Output: true
Explanation:
word1 represents string "ab" + "c" -> "abc"
word2 represents string "a" + "bc" -> "abc"
The strings are the same, so return true.
思路:
1.拼接起来判断是否相等。
JavaCode:
class Solution {
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
StringBuilder s1 = new StringBuilder();
StringBuilder s2 = new StringBuilder();
for(String w : word1)
s1.append(w);
for(String w : word2)
s2.append(w);
return s1.toString().equals(s2.toString());
}
}
靠北 这啥白痴题
https://i.imgur.com/HLS8By9.gif