File tree Expand file tree Collapse file tree 5 files changed +300108
-0
lines changed Expand file tree Collapse file tree 5 files changed +300108
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ leetcode 测试
10
10
11
11
##### 包含的内容如下
12
12
13
+ https://leetcode.cn/problems/zero-matrix-lcci/
14
+
15
+ https://leetcode.cn/problems/fancy-sequence
16
+
13
17
https://leetcode.cn/problems/regions-cut-by-slashes/
14
18
15
19
https://leetcode.cn/problems/minimum-amount-of-time-to-collect-garbage/
Original file line number Diff line number Diff line change
1
+ export default class Fancy {
2
+ #l: number [ ] = [ ] ;
3
+ #a = [ 0n ] ;
4
+ #m = [ 1n ] ;
5
+ constructor ( ) { }
6
+
7
+ append ( val : number ) : void {
8
+ this . #l. push ( val ) ;
9
+ this . #a. push ( this . #a. at ( - 1 ) as bigint ) ;
10
+ this . #m. push ( this . #m. at ( - 1 ) as bigint ) ;
11
+ }
12
+
13
+ addAll ( inc : number ) : void {
14
+ this . #a[ this . #a. length - 1 ] += BigInt ( inc ) ;
15
+ }
16
+
17
+ multAll ( m : number ) : void {
18
+ this . #a[ this . #a. length - 1 ] *= BigInt ( m ) ;
19
+ this . #m[ this . #m. length - 1 ] *= BigInt ( m ) ;
20
+ }
21
+
22
+ getIndex ( idx : number ) : number {
23
+ if ( idx >= this . #l. length ) return - 1 ;
24
+ const m = ( this . #m. at ( - 1 ) as bigint ) / this . #m[ idx ] ;
25
+ const c = ( this . #a. at ( - 1 ) as bigint ) - this . #a[ idx ] * m ;
26
+
27
+ return Number ( ( BigInt ( this . #l[ idx ] ) * m + c ) % BigInt ( 1e9 + 7 ) ) ;
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments