> Please tell the approach
How many chess boards have you drawn on paper?
How many times have you tried to manually fill the board with knights, using the rules described in the quiz?
> I tried backtracking but its too complicated and difficult to check for rectangles
Because, like all codechef problems, BRUTE FORCE DOES NOT WORK!!!!
How many times do you lot need to be told this?
If you have the right arrangement strategy, there will be NO rectangles to begin with, so there is no need to even bother checking there are rectangles, much less the need for massively expensive backtracking algorithms to try a different guess.