Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 621 Bytes

Question_3274.md

File metadata and controls

20 lines (17 loc) · 621 Bytes

LeetCode Records - Question 3274 Check if Two Chessboard Squares Have the Same Color

Attempt 1: Check the parities of horizontal and vertical positions

class Solution {
    public boolean checkTwoChessboards(String coordinate1, String coordinate2) {
        return isBlack(coordinate1) == isBlack(coordinate2);
    }

    private boolean isBlack(String coordinate) {
        char ch1 = coordinate.charAt(0);
        char ch2 = coordinate.charAt(1);
        return (ch1 - 'a') % 2 == (ch2 - '1') % 2;
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 41.90 MB (Beats: 100.00%)