Skip to content

Commit d6a081a

Browse files
committed
Runtime: 11 ms (Top 40.95%) | Memory: 94.7 MB (Top 51.18%)
1 parent 69c9483 commit d6a081a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1+
// Runtime: 11 ms (Top 40.95%) | Memory: 94.7 MB (Top 51.18%)
2+
13
class Solution {
24
public long gridGame(int[][] grid) {
35
int n = grid[0].length;
46
long preRow1[] = new long[n];
57
long preRow2[] = new long[n];
6-
8+
79
preRow1[0] = grid[0][0];
810
preRow2[0] = grid[1][0];
9-
11+
1012
for(int i = 1;i<n;i++){
1113
preRow1[i] += (long)preRow1[i-1] + (long)grid[0][i];
1214
preRow2[i] += (long)preRow2[i-1] + (long)grid[1][i];
1315
}
14-
16+
1517
long res = Long.MAX_VALUE;
1618
for(int i = 0;i<n;i++){
1719
long top = preRow1[n-1] - preRow1[i];
1820
long bottom = i == 0 ? 0 : preRow2[i-1];
1921
long temp = Math.max(top,bottom);
2022
res = Math.min(res,temp);
2123
}
22-
24+
2325
return res;
2426
}
25-
}
27+
}

0 commit comments

Comments
 (0)