Skip to content

Commit bd8583a

Browse files
Update max_chunks_to_make_sorted_ii.cpp
1 parent c1f96c4 commit bd8583a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

max_chunks_to_make_sorted_ii.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ class Solution {
1010

1111
int N = arr.size();
1212
vector<int> trackRightMin(N);
13-
int result = 0, max_ = 0;
13+
int result = 0, max_ = INT_MIN;
1414

15+
16+
trackRightMin[N-1] = arr[N-1];
1517
for(int i=N-2; i>=0; --i)
16-
trackRightMin[i] = min(arr[i+1], arr[i]);
18+
trackRightMin[i] = min(trackRightMin[i+1], arr[i]);
1719

1820
for(int i=0; i<N-1; ++i) {
1921
max_ = max(max_, arr[i]);

0 commit comments

Comments
 (0)