Skip to content

Commit 8ab0b20

Browse files
authored
Update 1499.Max-Value-of-Equation.cpp
1 parent 6c6ef96 commit 8ab0b20

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Deque/1499.Max-Value-of-Equation/1499.Max-Value-of-Equation.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ class Solution {
1010
q.pop_front();
1111
}
1212

13+
if (q.size() > 0) {
14+
ret = max(ret, -points[q.front()][0]+points[q.front()][1] + points[i][0]+points[i][1]);
15+
}
16+
1317
while (q.size()>0 && -points[q.back()][0]+points[q.back()][1] < -points[i][0]+points[i][1]) {
1418
q.pop_back();
1519
}
1620

1721
q.push_back(i);
1822

19-
if (q.size() > 0) {
20-
ret = max(ret, -points[q.front()][0]+points[q.front()][1] + points[i][0]+points[i][1]);
21-
}
23+
2224
}
2325
return ret;
2426
}

0 commit comments

Comments
 (0)