leetcode_c++:Game of Life(289)
来源:互联网 发布:excelplus电子表格mac 编辑:程序博客网 时间:2024/06/05 18:52
题目
According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”
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):
Any live cell with fewer than two live neighbors dies, as if caused by under-population.
Any live cell with two or three live neighbors lives on to the next generation.
Any live cell with more than three live neighbors dies, as if by over-population..
Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
Write a function to compute the next state (after one update) of the board given its current state.
Follow up:
Could you solve it in-place? Remember that the board needs to be updated at the same time: You cannot update some cells first and then use their updated values to update other cells.
In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches the border of the array. How would you address these problems?
算法
http://www.cnblogs.com/grandyang/p/4854466.html
- leetcode_c++:Game of Life(289)
- [289]Game of Life
- 289: Game of Life
- leetcode 289: Game of Life
- [leetcode 289]Game of Life
- [LeetCode 289] Game of Life
- [leetcode 289]Game of Life
- Game of Life leetcode 289
- LeetCode 289 Game of Life
- [leetcode 289] Game of Life
- LeetCode 289---Game of Life
- leetcode 289: Game of Life
- LeetCode.289 Game of Life
- [leetcode-289]Game of Life(java)
- LeetCode(289)Game of Life
- Leetcode 289 - Game of Life(array)
- Game of Life
- Game Of Life
- android中的安装删除程序的流氓方法
- IOS系列-responseToSelector
- Java Socket简单例子、readLine()、readUTF()
- Linux PATH 设置
- 机器学习模型性能测试结果(R或者python),逻辑回归的测试结果没有添加
- leetcode_c++:Game of Life(289)
- Java项目导出源代码jar包在Eclipse中查看中文注释乱码的问题
- Python的method, class method, static method
- Android平台证件识别系统
- JQ-事件-1
- SICP 练习2.30 square-tree
- ACM集训--打字训练
- python连接mongodb并进行用户验证
- Android开发之自定义控件