Leetcode Problem 1812. Determine Color of a Chessboard Square

1812. Determine Color of a Chessboard Square

Leetcode Solutions

Determining Chessboard Square Color by Coordinate Parity

  1. Convert the file (letter) part of the coordinate to an integer representing its position in the alphabet (e.g., 'a' to 1, 'b' to 2, etc.).
  2. Convert the rank (number) part of the coordinate to an integer.
  3. Check the parity of both the file and rank.
  4. If both are odd or both are even, return false (the square is black).
  5. Otherwise, return true (the square is white).
UML Thumbnail

Chessboard Square Color by Coordinate Sum

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...