-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3274.java
25 lines (22 loc) · 896 Bytes
/
_3274.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.fishercoder.solutions.fourththousand;
import java.util.HashSet;
import java.util.Set;
public class _3274 {
public static class Solution1 {
public boolean checkTwoChessboards(String coordinate1, String coordinate2) {
return isBlack(coordinate2) == isBlack(coordinate1);
}
private boolean isBlack(String coordinate) {
Set<Character> blackColsWithOddRows = new HashSet<>();
blackColsWithOddRows.add('a');
blackColsWithOddRows.add('c');
blackColsWithOddRows.add('e');
blackColsWithOddRows.add('g');
if (blackColsWithOddRows.contains(coordinate.charAt(0))) {
return Character.getNumericValue(coordinate.charAt(1)) % 2 == 1;
} else {
return Character.getNumericValue(coordinate.charAt(1)) % 2 == 0;
}
}
}
}