Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
leetcode1030
class Solution:
def allCellsDistOrder(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]:
class Solution:
def allCellsDistOrder(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]:
cells = [[i, j] for j in range(C) for i in range(R)]
def md(x, y, r0, c0):
return abs(r0 -x) + abs(c0 - y)
return sorted(cells, key=lambda x:md(x[0], x[1], r0, c0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.