Skip to content

Commit

Permalink
[LEET-3274] add 3274
Browse files Browse the repository at this point in the history
  • Loading branch information
fishercoder1534 committed Oct 28, 2024
1 parent d464578 commit be32346
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions paginated_contents/algorithms/4th_thousand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| 3289 | [The Two Sneaky Numbers of Digitville](https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3289.java) | | Easy |
| 3285 | [Find Indices of Stable Mountains](https://leetcode.com/problems/find-indices-of-stable-mountains/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3285.java) | | Easy |
| 3280 | [Convert Date to Binary](https://leetcode.com/problems/convert-date-to-binary/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3280.java) | | Easy |
| 3274 | [Check if Two Chessboard Squares Have the Same Color](https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3274.java) | | Easy |
| 3270 | [Find the Key of the Numbers](https://leetcode.com/problems/find-the-key-of-the-numbers/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3270.java) | | Easy |
| 3264 | [Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3264.java) | | Easy |
| 3263 | [Convert Doubly Linked List to Array I](https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3263.java) | | Easy |
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/fishercoder/solutions/fourththousand/_3274.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
}
}
}

0 comments on commit be32346

Please sign in to comment.