← 返回 meta 的题目列表Dry Run Array Problems
类型:online_judge
Given an integer array nums, for each nums[i], return the product of all elements of nums except nums[i]. Note that you must do it without division and in O(n) time complexity. Additionally, for a 2D matrix consisting of 0s and 1s, simulate the next generation of the game of life. Each cell interacts with its eight neighbors (adjacent horizontally, vertically, and diagonally) using the following rules:
Any live cell with two or three live neighbors survives.
Any live cell with fewer than two or more than three live neighbors dies.
Any dead cell with exactly three live neighbors becomes a live cell.
Given an initial state matrix, output the matrix of the next state.
Example
Input
nums = [1, 2, 3, 4]
board = [[0, 1, 0], [1, 1, 1], [0, 0, 0]]