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