private boolean doesLive(int x, int y, int[][] board) {
        int count = 0;
        for (int i = x - 1; i <= x + 1; i++) {
            for (int j = y - 1; j <= y + 1; j++) {
                if (x == i && y == j) {
                    continue;
                }
                if (i < 0 || i >= board.length) {
                    break;
                }
                if (j < 0 || j >= board[0].length) {
                    continue;
                }
                count += board[i][j];
            }
        }
        if (board[x][y] == 1) {
            return count == 2 || count == 3;
        } else {
            return count == 3;
        }
    }
Date 10/20/2016
@author Tushar Roy
Given a board with m by n cells, each cell has an initial state live (1) or dead (0).
Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following
four rules (taken from the above Wikipedia article):
Read full qs on leetcode.

Solution - Keep two array prev and current. Fill the values in current array. As soon as current row is done
replace elemments of board with prev array.

Time complexity O(n * m)

https://leetcode.com/problems/game-of-life/
src/com/interview/multiarray/GameOfLife.java