From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Sample interview question #3: 2D array

Sample interview question #3: 2D array

From the course: Get Ready for Your Coding Interview

Sample interview question #3: 2D array

- Here sampling to be question number three with two dimensional array. Here's the problem. You're given a configuration of a chess board with some rooks. In this chess board, we want to see if any of the rooks are able to attack any other ones. Just in case you've never played chess. Rooks are able to move any number of spaces, horizontally and vertically. So in this particular state, none of the roots are able to attack each other. However, in this one, the two roots at the top are able to attack each other. The configuration of the board will be given as an input to your function and I'll be represented as a two dimensional array. Zero means that there is nothing in that space and one means that there's a rook there. Very simple, and the given board could have a smaller size than the real chess board. For example, a four by four grade you see here, let's call this function rooks are safe, and we're going to…

Contents