Check if Two Chessboard Squares Have the Same Color

You are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard.

Return true if these two squares have the same color and false otherwise.

The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, indicating its column, and the number second, indicating its row.

Example 1
Inputcoordinate1 = "a1", coordinate2 = "c3"
Outputtrue
Both squares are black.
Example 2
Inputcoordinate1 = "a1", coordinate2 = "h3"
Outputfalse
Square "a1" is black and "h3" is white.

Constraints

  • coordinate1.length == coordinate2.length == 2
  • 'a' <= coordinate1[0], coordinate2[0] <= 'h'
  • '1' <= coordinate1[1], coordinate2[1] <= '8'

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate