Re: [閒聊] 每日LeetCode

作者: ZooseWu (N5)   2023-12-01 09:52:42
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('')
}
作者: ZooseWu (N5)   2023-12-01 09:56:00
這題送分題
作者: smart0eddie (smart0eddie)   2023-12-01 10:20:00
這是不是想考字串比較的function 實作
作者: ZooseWu (N5)   2023-12-01 10:31:00
不清楚 他難度只有easy

Links booklink

Contact Us: admin [ a t ] ucptt.com