Skip to main content
Back to problems
Leetcode
Easy
Math
Strings
Bit Manipulation
Check If Two Chessboard Squares Have The Same Color

Determine whether two chessboard squares have the same color.

Acceptance 0%
Problem Statement

Problem

You are given the coordinates of two squares on a standard 8×8 chessboard, such as a1 and c3.

A chessboard alternates colors between adjacent squares. Your task is to determine whether the two given squares have the same color.

Return true if both squares are the same color, otherwise return false.

Notes

  • Columns are labeled a through h.
  • Rows are labeled 1 through 8.
  • The color pattern alternates both horizontally and vertically.

Input Format

  • Two strings coordinate1 and coordinate2.
  • Each string has length 2.
  • The first character is a lowercase letter from a to h.
  • The second character is a digit from 1 to 8.

Output Format

  • Return a boolean value indicating whether the two squares have the same color.

Constraints

  • coordinate1 and coordinate2 are valid chessboard coordinates.
  • The board is the standard 8×8 chessboard.
  • You should solve this without building the entire board.
Examples
Sample cases returned by the problem API.

Example 1

Input

coordinate1 = "a1", coordinate2 = "c3"

Output

true

Explanation

Both squares are dark on a standard chessboard, so they have the same color.

Example 2

Input

coordinate1 = "a1", coordinate2 = "h3"

Output

false

Explanation

a1 and h3 have opposite colors.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.