![]() |
VOOZH | about |
There is an 8*8 chessboard and two chess players having a single pawn each. A player has to move his pawn in each turn, either one step forward or one step diagonally only when this move kills the other pawn. The player who is unable to make any move loses.
Given row and column numbers of white and black pawns. The task is to predict who would win assuming both plays optimally. Note that White plays first and a pawn cannot move outside the chessboard.
Examples:
Input: rowW = 2, colW = 2, rowB = 3, colB = 3
Output: White
Input: rowW = 2, colW = 2, rowB = 3, colB = 3
Output: White
Approach:
Below is the implementation of the above approach:
White
Time Complexity: O(1) as the time is constant.
Auxiliary Space: O(1)