About the logic of elephant in chess qstn

I didn’t understand why we are summing up the values of the corresponding row and column to get the value of a cell x, y?

Hello @Senjuti256 we are summing up because its about we have to find the total number of options we have to reach that x and y location in the matrix.
That is the reason we are summing up like this.
Because we have to find the sum of all the options thats we are adding values for previous rows and columns also.
If you still have doubt you can ask here.
Happy Learning!!

basically why to add all elements of that row and column? in the rat variant we were adding only 2 values that is the left and top cell only.

hey @Senjuti256 rat can move only one step so if we are at x,y position then dp[x-1][y]+dp[x][y-1] will store all the required options but the same is not true with elephant case thats why we have to take sum of whole row and columns in elephants case.

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.