Cold storage hot spots

Write codeEasy16 min

Your task

A cold storage room reports temperatures from a rectangular grid of sensors, one reading per cell in tenths of a degree. A cell is a hot spot when its reading is strictly greater than the reading of every sensor directly above, below, left of and right of it. Sensors on an edge or in a corner simply have fewer neighbours to beat, and diagonal neighbours never count. Return the coordinates of every hot spot as [row, column] pairs, ordered by row and then by column. A tie with any orthogonal neighbour disqualifies a cell, so a room where every sensor reads the same has no hot spots at all. A grid with no sensors returns an empty list.

Examples

hot_spot_cells(readings: list[list[int]]) -> list[list[int]]
Example 1
Inputhot_spot_cells([[1, 2, 1], [2, 9, 2], [1, 2, 1]])
Output[[1, 1]]
Example 2
Inputhot_spot_cells([[5, 5], [5, 5]])
Output[]
Example 3
Inputhot_spot_cells([[3, 1, 4], [1, 5, 9]])
Output[[0, 0], [1, 2]]