Created
April 22, 2019 01:02
-
-
Save showyou/56b9f7a0f1b6fa59c2124180def989f2 to your computer and use it in GitHub Desktop.
leetcode1030
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def allCellsDistOrder(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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