![]() |
VOOZH | about |
Given the position of the queen (qX, qY) and the opponent (oX, oY) on a chessboard. The task is to determine whether the queen can attack the opponent or not. Note that the queen can attack in the same row, same column and diagonally.
Example:
Input: qX = 4, qY = 5, oX = 6, oY = 7
Output: Yes
The queen can attack diagonally.Input: qX = 1, qY = 1, oX = 3, oY = 2
Output: No
Approach:
If all of the above conditions fail then the opponent is safe from the queen.
Below is the implementation of the above approach:
No
Time complexity: O(1)
Auxiliary space: O(1)