3
self, rows: int, cols: int, rCenter: int, cCenter: int5
# create a r, c matrix given the rows & cols6
# each element represents a list [r, c] where r is the row & c the col7
# find find the distances of all cells from the center (append to res)8
# sort the result by distance function9
# Time O(M + N) Space O(M + N)12
return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])14
matrix = [[i, j] for i in range(rows) for j in range(cols)]15
center = [rCenter, cCenter]16
matrix.sort(key=lambda c: distance(c, center))