Skip to content

Commit 584b914

Browse files
authored
Improved task 3001
1 parent 114ed8b commit 584b914

File tree

1 file changed

+6
-7
lines changed
  • src/main/java/g3001_3100/s3001_minimum_moves_to_capture_the_queen

1 file changed

+6
-7
lines changed

src/main/java/g3001_3100/s3001_minimum_moves_to_capture_the_queen/Solution.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
package g3001_3100.s3001_minimum_moves_to_capture_the_queen;
22

3-
// #Medium #Array #Enumeration #2024_02_25_Time_0_ms_(100.00%)_Space_40.7_MB_(78.00%)
3+
// #Medium #Array #Enumeration #2024_11_08_Time_0_ms_(100.00%)_Space_41_MB_(27.27%)
44

55
public class Solution {
66
public int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
77
if (a == e || b == f) {
8-
if (a == c && (d > b && d < f || d > f && d < b)) {
8+
if (a == e && a == c && (d - b) * (d - f) < 0) {
99
return 2;
1010
}
11-
if (b == d && (c > a && c < e || c > e && c < a)) {
11+
if (b == f && b == d && (c - a) * (c - e) < 0) {
1212
return 2;
1313
}
1414
return 1;
15-
} else if (Math.abs(c - e) == Math.abs(d - f)) {
16-
if (Math.abs(a - c) == Math.abs(b - d)
17-
&& Math.abs(e - a) == Math.abs(f - b)
18-
&& (a > e && a < c || a > c && a < e)) {
15+
}
16+
if (Math.abs(c - e) == Math.abs(d - f)) {
17+
if (Math.abs(c - a) == Math.abs(d - b) && (b - f) * (b - d) < 0) {
1918
return 2;
2019
}
2120
return 1;

0 commit comments

Comments
 (0)