|
8 | 8 | import java.util.Queue;
|
9 | 9 | import java.util.Set;
|
10 | 10 |
|
11 |
| -/** |
12 |
| - * 444. Sequence Reconstruction |
13 |
| - * |
14 |
| - * Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. |
15 |
| - * The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. |
16 |
| - * Reconstruction means building a shortest common supersequence of the sequences in seqs |
17 |
| - * (i.e., a shortest sequence so that all sequences in seqs are subsequences of it). |
18 |
| - * Determine whether there is only one sequence that can be reconstructed from seqs and it is the org sequence. |
19 |
| -
|
20 |
| - Example 1: |
21 |
| - Input: |
22 |
| - org: [1,2,3], seqs: [[1,2],[1,3]] |
23 |
| -
|
24 |
| - Output: |
25 |
| - false |
26 |
| -
|
27 |
| - Explanation: |
28 |
| - [1,2,3] is not the only one sequence that can be reconstructed, because [1,3,2] is also a valid sequence that can be reconstructed. |
29 |
| -
|
30 |
| - Example 2: |
31 |
| - Input: |
32 |
| - org: [1,2,3], seqs: [[1,2]] |
33 |
| -
|
34 |
| - Output: |
35 |
| - false |
36 |
| -
|
37 |
| - Explanation: |
38 |
| - The reconstructed sequence can only be [1,2]. |
39 |
| -
|
40 |
| - Example 3: |
41 |
| - Input: |
42 |
| - org: [1,2,3], seqs: [[1,2],[1,3],[2,3]] |
43 |
| -
|
44 |
| - Output: |
45 |
| - true |
46 |
| -
|
47 |
| - Explanation: |
48 |
| - The sequences [1,2], [1,3], and [2,3] can uniquely reconstruct the original sequence [1,2,3]. |
49 |
| -
|
50 |
| - Example 4: |
51 |
| - Input: |
52 |
| - org: [4,1,5,2,6,3], seqs: [[5,2,6,3],[4,1,5,2]] |
53 |
| -
|
54 |
| - Output: |
55 |
| - true |
56 |
| - */ |
57 | 11 | public class _444 {
|
58 | 12 | public static class Solution1 {
|
59 | 13 | /**
|
|
0 commit comments