HTML
from Uttam Vasishta S M (Cisco) to everyone: 11:20 AM
Here Array with chess board 8x8 matrix. Let’s assume all 1’s are place where king can’t move and 0’s are place where king can move. Find out how many possible move is there for king for given position?
[[1,1,1,1,1,1,1,1],
[1,0,1,1,0,0,1,0],
[1,0,1,0,0,0,1,0],
[1,0,1,1,0,0,1,0],
[1,0,1,1,0,1,1,0],
[1,0,1,1,0,0,1,0],
[1,0,1,1,0,1,1,0],
[1,0,1,1,0,0,1,0]]
Example run below :
Input current king position —> 3,3
[0,1,1],
0,1,0
0,1,1
Output will be —> 4 ( as there are 4 0’s where king can move)