File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
partition-array-into-disjoint-intervals Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ Step 2. Add the dependency
45
45
46
46
<summary >展开查看</summary >
47
47
48
+ https://leetcode.cn/problems/partition-array-into-disjoint-intervals/
49
+
48
50
https://leetcode.cn/problems/maximum-profit-in-job-scheduling/
49
51
50
52
https://leetcode.cn/problems/booking-concert-tickets-in-groups/
Original file line number Diff line number Diff line change
1
+ export default function partitionDisjoint ( nums : number [ ] ) : number {
2
+ const n = nums . length ;
3
+ let leftMax = nums [ 0 ] ,
4
+ leftPos = 0 ,
5
+ curMax = nums [ 0 ] ;
6
+ for ( let i = 1 ; i < n - 1 ; i ++ ) {
7
+ curMax = Math . max ( curMax , nums [ i ] ) ;
8
+ if ( nums [ i ] < leftMax ) {
9
+ leftMax = curMax ;
10
+ leftPos = i ;
11
+ }
12
+ }
13
+ return leftPos + 1 ;
14
+ }
You can’t perform that action at this time.
0 commit comments