精華區beta Marginalman 關於我們 聯絡資訊
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
ZooseWu: 這題送分題 12/01 09:56
smart0eddie: 這是不是想考字串比較的function 實作 12/01 10:20
ZooseWu: 不清楚 他難度只有easy 12/01 10:31