Skip to content

Instantly share code, notes, and snippets.

@showyou
Created April 22, 2019 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save showyou/56b9f7a0f1b6fa59c2124180def989f2 to your computer and use it in GitHub Desktop.
Save showyou/56b9f7a0f1b6fa59c2124180def989f2 to your computer and use it in GitHub Desktop.
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