target of distinct numbers and a collection fragments of short arrays. Taken together, the numbers across all fragments are distinct as well, and the fragment lengths add up to the length of target.
You may lay the fragments end to end in any order, but you may not rearrange the numbers inside a fragment. Return True if this can produce exactly target, and False otherwise.target=[7, 3, 9, 1], fragments=[[9, 1], [7, 3]] → True
Put [7, 3] first and then [9, 1].
target=[5, 6, 2], fragments=[[6, 5], [2]] → False
The numbers match, but the order inside [6, 5] is fixed, while the target needs 5 before 6.
target=[4, 8], fragments=[[4], [3]] → False
target are distinct, and so are all numbers across the fragmentstarget=[7, 3, 9, 1], fragments=[[9, 1], [7, 3]]
True
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.