@@ -23,7 +23,10 @@ class Solution {
23
23
var s: Long = 0
24
24
for (i in 0 .. < r.size - 1 ) {
25
25
s + = r[i].toLong()
26
- if (s * 2 == total || s * 2 - grid[i][n - 1 ] == total || s * 2 - grid[i][0 ] == total || s * 2 - grid[0 ][0 ] == total || s * 2 - grid[0 ][n - 1 ] == total) {
26
+ if (s * 2 == total || s * 2 - grid[i][n - 1 ] == total ||
27
+ s * 2 - grid[i][0 ] == total || s * 2 - grid[0 ][0 ] == total ||
28
+ s * 2 - grid[0 ][n - 1 ] == total
29
+ ) {
27
30
return true
28
31
}
29
32
if (s * 2 > total) {
@@ -33,7 +36,10 @@ class Solution {
33
36
s = 0
34
37
for (i in m - 1 downTo 0 ) {
35
38
s + = r[i].toLong()
36
- if (s * 2 == total || s * 2 - grid[i][n - 1 ] == total || s * 2 - grid[i][0 ] == total || s * 2 - grid[m - 1 ][n - 1 ] == total || s * 2 - grid[m - 1 ][0 ] == total) {
39
+ if (s * 2 == total || s * 2 - grid[i][n - 1 ] == total ||
40
+ s * 2 - grid[i][0 ] == total || s * 2 - grid[m - 1 ][n - 1 ] == total ||
41
+ s * 2 - grid[m - 1 ][0 ] == total
42
+ ) {
37
43
return true
38
44
}
39
45
if (s * 2 > total) {
@@ -45,7 +51,9 @@ class Solution {
45
51
for (ints in grid) {
46
52
s + = ints[i].toLong()
47
53
}
48
- if (s * 2 == total || s * 2 - grid[0 ][0 ] == total || s * 2 - grid[m - 1 ][0 ] == total || s * 2 - grid[0 ][i] == total || s * 2 - grid[m - 1 ][i] == total) {
54
+ if (s * 2 == total || s * 2 - grid[0 ][0 ] == total || s * 2 - grid[m - 1 ][0 ] == total ||
55
+ s * 2 - grid[0 ][i] == total || s * 2 - grid[m - 1 ][i] == total
56
+ ) {
49
57
return true
50
58
}
51
59
if (s * 2 > total) {
@@ -57,7 +65,9 @@ class Solution {
57
65
for (j in m - 1 downTo 0 ) {
58
66
s + = grid[j][i].toLong()
59
67
}
60
- if (s * 2 == total || s * 2 - grid[m - 1 ][n - 1 ] == total || s * 2 - grid[0 ][n - 1 ] == total || s * 2 - grid[0 ][i] == total || s * 2 - grid[m - 1 ][i] == total) {
68
+ if (s * 2 == total || s * 2 - grid[m - 1 ][n - 1 ] == total || s * 2 - grid[0 ][n - 1 ] == total ||
69
+ s * 2 - grid[0 ][i] == total || s * 2 - grid[m - 1 ][i] == total
70
+ ) {
61
71
return true
62
72
}
63
73
if (s * 2 > total) {
0 commit comments