question- https://hack.codingblocks.com/app/contests/1289/265/problem
my code- https://ide.codingblocks.com/s/215731
i dont get it why it is not solving
question- https://hack.codingblocks.com/app/contests/1289/265/problem
my code- https://ide.codingblocks.com/s/215731
i dont get it why it is not solving
Hello @anubhavb11,
First, cross verify your code with https://ide.codingblocks.com/s/267940
Let me know if you still can’t find the mistake.
both the approach are tottaly different can you please have a look at my code i want to know what is mistake in my code.
2nd i am not able to understand issafe in your code+ i am not familiar with java + what is xInc and yInc
Hey @anubhavb11,
Pardon me. I have mistakenly send the wrong code:
BTW, your output format doesn’t matches with that of the question.
usually, first I want to get the correct answer and verify my logic is right when i get it then i correct the output format can u please check my code if the logic is correct.
Hey @anubhavb11,
Mistakes in your code:
Question reads: We are asked to place N number of Knights in it.
There is no condition in your code for this while it is present in the code i have shared.
You are not counting the total number of possible placements which is also the requirement of the question.
You have to check for the following 8 moves:
{-1,-2}, {-2,-1}, {-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}
while you are checking for only 4 moves.
Correct these.
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.