File tree 3 files changed +41
-1
lines changed
3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } gain
3
+ * @return {number }
4
+ */
5
+ const largestAltitude = ( gain ) => {
6
+ let max = 0 , acc = 0
7
+
8
+ for ( let i = 0 ; i < gain . length ; i ++ ) {
9
+ acc += gain [ i ]
10
+ max = Math . max ( max , acc )
11
+ }
12
+
13
+ return max ;
14
+ } ;
15
+
16
+ // /**
17
+ // * @param {number[] } gain
18
+ // * @return {number }
19
+ // */
20
+ // const largestAltitude = (gain) => {
21
+ // let max = 0, tmpMax = 0;
22
+ // for (let i = 0; i < gain.length; i++) {
23
+ // tmpMax += gain[i];
24
+ // max = Math.max(max, tmpMax);
25
+ // }
26
+ // return max;
27
+ // };
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } gain
3
+ * @return {number }
4
+ */
5
+ const largestAltitude = ( gain ) => {
6
+ let max = 0 , tmpMax = 0 ;
7
+ for ( let i = 0 ; i < gain . length ; i ++ ) {
8
+ tmpMax += gain [ i ] ;
9
+ max = Math . max ( max , tmpMax ) ;
10
+ }
11
+ return max ;
12
+ } ;
Original file line number Diff line number Diff line change 112
112
- [ 1572. Matrix Diagonal Sum] ( ./1572/ )
113
113
- [ 1672. Richest Customer Wealth] ( ./1672/ )
114
114
- [ 1679. Max Number of K-Sum Pairs] ( ./1679/ )
115
+ - [ 1732. Find the Highest Altitude] ( ./1732/ )
115
116
- [ 1768. Merge Strings Alternately] ( ./1768/ )
116
117
- [ 1791. Find Center of Star Graph] ( ./1791/ )
117
118
- [ 1909. Remove One Element to Make the Array Strictly Increasing] ( ./1909/ )
@@ -166,7 +167,7 @@ Batch create:
166
167
NOTE: JS IS HERE
167
168
-->
168
169
``` ssh
169
- chapter=1493 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
170
+ chapter=1732 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
170
171
```
171
172
> then you can use ` x ` for quick debug.
172
173
You can’t perform that action at this time.
0 commit comments