File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -896,6 +896,10 @@ https://leetcode.cn/problems/cells-with-odd-values-in-a-matrix/
896
896
897
897
https://leetcode.cn/problems/set-intersection-size-at-least-two
898
898
899
+ https://leetcode.cn/problems/sequence-reconstruction/
900
+
901
+ https://leetcode.cn/problems/ur2n8P/
902
+
899
903
#### 安装教程
900
904
901
905
1 . 安装` deno `
Original file line number Diff line number Diff line change
1
+ import sequenceReconstruction from "../ur2n8P/index.ts" ;
2
+
3
+ export default sequenceReconstruction ;
Original file line number Diff line number Diff line change
1
+ function sequenceReconstruction (
2
+ nums : number [ ] ,
3
+ sequences : number [ ] [ ] ,
4
+ ) : boolean {
5
+ const s = new Set < string > ( ) ;
6
+ for ( const seq of sequences ) {
7
+ for ( let i = 0 ; i < seq . length - 1 ; i ++ ) {
8
+ s . add ( hash ( seq [ i ] , seq [ i + 1 ] ) ) ;
9
+ }
10
+ }
11
+ for ( let i = 0 ; i < nums . length - 1 ; i ++ ) {
12
+ if ( ! s . has ( hash ( nums [ i ] , nums [ i + 1 ] ) ) ) {
13
+ return false ;
14
+ }
15
+ }
16
+ return true ;
17
+ }
18
+
19
+ function hash ( arg0 : number , arg1 : number ) : string {
20
+ return JSON . stringify ( [ arg0 , arg1 ] ) ;
21
+ }
22
+ export default sequenceReconstruction ;
You can’t perform that action at this time.
0 commit comments