Skip to content
Discussion options

You must be logged in to vote

@LPenny-github

題目會給兩個 arr,一個裝 不重複的整數,另一個裝 不重複的整數片段(?)。
在 片段(?) 裡的也是不重複的整數。

是的。

題目的要求是:「如果那些片段 (pieces) 可以以某種次序連起來組成 arr ,就傳回 true ;否則,傳回 false 。」


可以把這想成「拼圖」。

以 LeetCode 原題的 "Example 4" 來說:

  • 拼圖碎片 pieces 有 3 塊: [78], [4,64], [91]
  • 最後想要的樣子 arr[91,4,64,78]
  • 答案為 true
    • 因為可以用 [91], [4,64], [78] 的方式將 pieces 組成 arr 的樣子

以 LeetCode 原題的 "Example 3" 來說:

  • 拼圖碎片 pieces 有 1 塊: [16,18,49]
  • 最後想要的樣子 arr[49,18,16]
  • 答案為 false
    • pieces 給我們唯一的片段是 [16,18,49], 怎麼樣也無法組成 arr 的樣子
    • 因為題目有明確規定「不可變動片段中的成員的順序」
      • However, you are not allowed to reorder the integers in each array pieces[i]

      • 也就是不能把 [16,18,49] 變成 [49,18,16]
      • 在 "Example 4" 裡,我們變動的是片段( pieces ) 的順序,也就是將 [78], [4,64], [91] 變成 [91], [4,64], [78], 但我們沒有去變動「…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LPenny-github
Comment options

Answer selected by LPenny-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants