File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ Step 2. Add the dependency
47
47
48
48
https://leetcode.cn/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/
49
49
50
+ https://leetcode.cn/problems/champagne-tower
51
+
50
52
https://leetcode.cn/problems/last-stone-weight-ii/
51
53
52
54
https://leetcode.cn/problems/delete-characters-to-make-fancy-string/
Original file line number Diff line number Diff line change
1
+ export default function champagneTower (
2
+ poured : number ,
3
+ query_row : number ,
4
+ query_glass : number ,
5
+ ) : number {
6
+ let row = [ poured ] ;
7
+ for ( let i = 1 ; i <= query_row ; i ++ ) {
8
+ const nextRow : number [ ] = new Array ( i + 1 ) . fill ( 0 ) ;
9
+ for ( let j = 0 ; j < i ; j ++ ) {
10
+ const volume = row [ j ] ;
11
+ if ( volume > 1 ) {
12
+ nextRow [ j ] += ( volume - 1 ) / 2 ;
13
+ nextRow [ j + 1 ] += ( volume - 1 ) / 2 ;
14
+ }
15
+ }
16
+ row = nextRow ;
17
+ }
18
+ return Math . min ( 1 , row [ query_glass ] ) ;
19
+ }
You can’t perform that action at this time.
0 commit comments