Matrix Saddle Points
A saddle point is a cell that is both the largest value in its row and the smallest value in its column. The function saddle_points receives a matrix matrix and finds all such cells. Return their coordinates as a list of [row, column] pairs, using 1-based indexing.
Примеры
Ввод
[[9, 8, 7], [5, 3, 2], [6, 6, 7]]Вывод
[[2, 1]]Ввод
[[1, 2, 3], [3, 1, 2], [2, 3, 1]]Вывод
[]Ввод
[[2]]Вывод
[[1, 1]]Нужно реализовать
def saddle_points(matrix: list[list[int]]) -> list[list[int]]:
Теги
arraylists
Logi sisse, et näha esituste ajalugu
Logi sisseLogi sisse, et kasutada AI mentorit
Logi sisseVisible tests
1
Input
[[9,8,7],[5,3,2],[6,6,7]]Expected
[[2,1]]2
Input
[[1,2,3],[3,1,2],[2,3,1]]Expected
[]3
Input
[[2]]Expected
[[1,1]]4
Input
[[4,5,4],[3,5,5],[1,5,4]]Expected
[[1,2],[2,2],[3,2]]5
Input
[]Expected
[]6
Input
[[1,2,3],[3,1,2],[2,3,1],[1,2,3],[3,1,2]]Expected
[]Focus radio
Paused · SomaFM · Fluid