Probability Of Knight In The Chessboard

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

1. You are given a N*N chessboard and the starting position of the knight in the chessboard.
2. The rows and columns are 0 indexed, so the top-left square is (0, 0), and the bottom-right square is (N-1, N-1).
3. You have to find the probability of knight to remain in the chessboard after exactly k number of moves.

Note -> The knight continues moving until it has made exactly K moves or has moved off the chessboard.
Input Format
A number N
A number K
Two numbers r and c(starting row and column position of knight in the chessboard).
Output Format
Check the sample output and question video.
Question Video
Constraints
1 <= N <= 25
0 <= K <= 100
0 <= r,c <= N-1
Sample Input
3
2
0
0
Sample Output
0.0625


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name