@manishkumar-qn6lx

Here is the C++  Code :

#include<bits/stdc++.h>
using namespace std;
#define N 8 

// Print the solution Matrix
void printSolution(int arr[N][N]){
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout<<arr[i][j]<<" ";
        }cout<<endl;
    }
}



// isSafe() to check all givin & boundary conditions 
bool isSafe(int x, int y, int val){
    if(x<N && y<N && x>=0 && y>=0 && val == 0)
        return true;
        
    return false;
}
    

// Function to fill the matrix with all possible moves
bool findAnswer(int arr[N][N], int row[N], int col[N], int x, int y, int k){
    
    for(int i=0; i<N; i++){
        
        if(isSafe(x+row[i], y+col[i], arr[x+row[i]][y+col[i]])){
            
            arr[x+row[i]][y+col[i]] = k;
            
            if(k==64){
                printSolution(arr);
                return true;
            }
           
            if(findAnswer(arr, row, col, x+row[i], y+col[i], k+1))
                return true;  
            
            arr[x+row[i]][y+col[i]] = 0;
        }
    }
    
    return false;
    
}

int main(){
    int arr[N][N] = {};
    int row [] = {2, 1, -1, -2, -2, -1, 1, 2};
    int col [] = {1, 2, 2, 1, -1, -2, -2, -1};
    
    arr[0][0] = 1;
    findAnswer(arr, row, col, 0, 0, 2);
    return 0;
}

@justaboy5625

Just one thing to say dude you really nailed the explanation part of your code.

@chandrashekhar9470

MindBlowing Explanation!Keep Posting more such videos..Kudos

@mahendrapatidar8052

Hello sir, I found one issue. if we give moves in different order then it is not working. i.e. static 	int [] row = {-2, -2, 2, 2, -1, 1, -1, 1};
static	int [] col = {-1, 1, -1, 1, -2, -2, 2, 2};

@HIMANSHUSHARMA-eh5wv

Sir awesome videos !!
And hoping for more awesome content  to come!!
(:

@lifeincanada7763

Your explanation 👍

@amazinglife5400

Sir, but why do we not get answer if pathrow & pathcol changed as suggested by you in video as their positions will remain same only??

@ctbram0627

Tried several other starting positions.  [0,7] = reached 63 (failed) 18 times before finding a solution, [7,7] hit 63 27,586 times! and [7,0] failed 38 times.  I tried [4,4] and stopped the program after watching the entire movie First Man at 238,000 runs up to 63!!! So there could be some optimization.  I am thinking for each move attempt go to a square with the fewest number of a possible move from that position.

@taimoorhassan4624

you sound like you are sleepy. you need to make such videos with fresh voice please

@arpitasood2657

best resource:)

@amitchaudhary6917

In what order have u taken pathRow1 and pathCol1 in the code???

@sultanraffy9596

im sorry, but What is array [,] mean ?

@mingzhu8093

How do we know the knight already been to all the cells it could reach?

@harryroopan1627

Why we return true in if block

@e889.

This is the worst written code

@chestermartin2356

It was going ok then you just wrote a load of code and didn't explain anything 😅

@jaydalsaniya6986

Wasted my time watching someone writing the code without explaining ...

@jawadalkassim

I think you should take a nap then record a video,