Higher Than Its Neighbors
Return the [row, column] of every cell of grid that is strictly greater than each of its neighbors: the cells above, below, left and right of it. A cell on the edge has fewer neighbors. List the cells in reading order. No loops: for and while are not allowed.
Example 1
grid [[1,5,1],[2,1,6],[7,2,1]]
returns [[0,1],[1,2],[2,0]]
5 beats 1, 1 and 1. 6 beats 1, 1 and 1. 7 beats 2 and 2.
Constraints
1 <= rows, columns <= 12-9 <= grid[r][c] <= 9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Join Overlapping SpansHard
- Move the CentersHard
- Next GenerationHard
- Runs of Equal ValuesHard
- Two Closest PointsHard
- Vote of the NearestHard
- Above Average CountBeginner
- Average TemperatureBeginner