Skip to content

Commit b40f46b

Browse files
authored
Create maximize-the-number-of-partitions-after-operations.cpp
1 parent e4fec78 commit b40f46b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Time: O(1)
2+
// Space: O(1)
3+
4+
// math
5+
class Solution {
6+
public:
7+
int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
8+
if (a == e && !(a == c && (b - d) * (f - d) < 0)) {
9+
return 1;
10+
}
11+
if (b == f && !(b == d && (a - c) * (e - c) < 0)) {
12+
return 1;
13+
}
14+
if (c + d == e + f && !(c + d == a + b && (c - a) * (e - a) < 0)) {
15+
return 1;
16+
}
17+
if (c - d == e - f && !(c - d == a - b && (d - b) * (f - b) < 0)) {
18+
return 1;
19+
}
20+
return 2;
21+
}
22+
};

0 commit comments

Comments
 (0)