FastPrepValidate a Two-Color Chessboard
Problems/Validate a Two-Color Chessboard

Validate a Two-Color Chessboard

Amazon logoAmazon● EasyFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. The report names checking a grid with two colors and asks for several approaches. We chose the exact rule for neighbors, the sizes, and how the grid is written. Our version is about 90% the same as the reported question.

You are given a nonempty rectangular integer matrix board. Every cell is one of two colors, encoded as 0 or 1.

Return true if board is a valid chessboard pattern: every pair of horizontally adjacent cells has different colors, and every pair of vertically adjacent cells has different colors. Otherwise, return false.

Function

isValidChessboard(board: int[][]) → boolean

Examples

Example 1

board = [[0,1,0],[1,0,1]]return = true
board
01200101101

Every horizontal and vertical neighbor has the opposite color.

Example 2

board = [[0,1],[1,1]]return = false
board
01001111

The two cells in the bottom row have the same color, so the pattern is invalid.

Constraints

  • 1 <= board.length <= 100
  • 1 <= board[i].length <= 100
  • Every row has the same length.
  • board[i][j] is either 0 or 1.

More Amazon Onsite Interview questions

  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Rotate a Matrix by 90 DegreesIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
  • Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions
  • One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
  • Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN
  • Traverse Interior Matrix Cells in Row-Major OrderCitadel · ONSITE INTERVIEWCitadel interview questions
  • Trace an Eight-Direction Robot Until BlockedPinterest · PHONE SCREENPinterest interview questions
  • Detect a Winner on a 3x3 Tic-Tac-Toe BoardHebbia · ONSITE INTERVIEW
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public boolean isValidChessboard(int[][] board) {
        // Write your code here.
    }
}
Checking account…