Description
Given a sequence org and a list of sequences, check if org is the unique shortest supersequence that can be reconstructed from the sequences.
Examples
Input:
org = [1,2,3], seqs = [[1,2],[1,3]]Output:
falseExplanation:
Not unique.
Input:
org = [1,2,3], seqs = [[1,2],[1,3],[2,3]]Output:
trueExplanation:
For org = [1,2,3], seqs = [[1,2],[1,3],[2,3]], the answer is true because the sequence reconstruction condition is satisfied.
Input:
org = [4,1,5,2,6,3], seqs = [[5,2,6],[4,1,5],[1,5,2],[2,6,3]]Output:
trueExplanation:
The sequences provide enough ordering constraints to uniquely reconstruct the original sequence. From the sequences, it is possible to deduce: 4→1→5→2→6→3, which matches the original exactly.
Constraints
- •
1 ≤ org.length ≤ 10⁴