Re: [閒聊] 每日LeetCode已回收
1662. Check If Two String Arrays are Equivalent
給你兩個字串陣列
回傳兩個陣列是否表示相同字串
把陣列元素按順序連接在一起之後就是他的字串
Input: word1 = ["ab", "c"], word2 = ["a", "bc"]
Output: true
word1: "ab" + "c" -> "abc"
word2: "a" + "bc" -> "abc"
Input: word1 = ["a", "cb"], word2 = ["ab", "c"]
Output: false
Input: word1 = ["abc", "d", "defg"], word2 = ["abcddefg"]
Output: true
Approach:
用join合併之後直接比較
TS Code:
function arrayStringsAreEqual (word1: string[], word2: string[]): boolean {
return word1.join('') === word2.join('')
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.32.229.33 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1701395564.A.409.html
→
12/01 09:56,
2年前
, 1F
12/01 09:56, 1F
推
12/01 10:20,
2年前
, 2F
12/01 10:20, 2F
→
12/01 10:31,
2年前
, 3F
12/01 10:31, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 560 之 719 篇):