Imagine you're a puzzle master with a target array of distinct integers and a collection of puzzle pieces (smaller arrays). Your challenge is to determine if you can form the exact target array by arranging these pieces in any order you want!
Here's the twist: while you can rearrange the pieces themselves, you cannot change the order of numbers within each piece. It's like having puzzle pieces where the internal pattern is fixed, but you can place the pieces anywhere in the final picture.
Goal: Return true if you can perfectly reconstruct the target array using all the pieces, false otherwise.
Example: If arr = [15,88] and pieces = [[88],[15]], you can rearrange pieces to get [15,88] โ
Input & Output
Constraints
- 1 โค pieces.length โค arr.length โค 100
- Sum of pieces[i].length equals arr.length
- 1 โค pieces[i].length โค arr.length
- 1 โค arr[i], pieces[i][j] โค 100
- All integers in arr are distinct
- All integers in pieces are distinct