![]() ![]() Otherwise, it opens up all the neighboring cell, and recursively calls reveal on the neighbors.If a cell has non-zero neighbors with mines, it simply shows the number of neighbors with mines on that cell.Otherwise, the game reveals the cells using a recursive algorithm:.If the chosen cell contains a mine, the user loses immediately. At each turn, the user clicks on a cell of the board.A few unknown cells on the board have “mines” behind them. With these rules in mind, let’s take a quick look at what we are supposed to code. ![]() It’s okey to use additional storage/iterate over array multiple times or even to code an O(n 2) algorithm instead of O(nlogn). Big-Oh computation complexity is less important.Never write a single function (like you’d usually do on a whiteboard). Your code better work! Use compiler/interpreter/error messaging from your programming language as a friend and write an error-free program!.Here are a few ground rules for doing well in these interviews: Like we said before, live coding interview questions are fundamentally different from whiteboarding. In this next part of the series, we are going to give a similar demonstration of coding up an interactive Minesweeper game! Read on… In previous posts, we saw how to code a small interactive text-based Tic-Tac-Toe game, especially within time limit of a technical interview, and with unit tests. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |