Here in this solution i am using backtracking approach. In this problem we have to place a queens if possible in each row such that it is at safe position.
safe position here means:
for checking these three things i have made a funciton issafe();
and for solving the main problem recursively(using backtracking) i have made a solve function.