作者:
Rushia (みけねこ的鼻屎)
2022-10-25 09:18:521662. 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