In n queen n problem

i dont understand to check for diagonals

Hey Udit, diogonal check is necessary to see if queen attacks other queen or not. There are two types of diagonals,

  1. goes from top left to bottom right
    2 . goes from bottom left to top right.
    1st diagonal follows that difference of x and y coordinates is constant.
    2nd diagonal follows that sum of x and y is constant.
    We utilize above properties to find diagonal elements for given coordinates.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.