We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6c6ef96 commit 8ab0b20Copy full SHA for 8ab0b20
Deque/1499.Max-Value-of-Equation/1499.Max-Value-of-Equation.cpp
@@ -10,15 +10,17 @@ class Solution {
10
q.pop_front();
11
}
12
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
+
17
while (q.size()>0 && -points[q.back()][0]+points[q.back()][1] < -points[i][0]+points[i][1]) {
18
q.pop_back();
19
20
21
q.push_back(i);
22
- if (q.size() > 0) {
- ret = max(ret, -points[q.front()][0]+points[q.front()][1] + points[i][0]+points[i][1]);
- }
23
24
25
return ret;
26
0 commit comments