Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 974 Bytes

_1030. Matrix Cells in Distance Order.md

File metadata and controls

33 lines (22 loc) · 974 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 04, 2024

Last updated : July 01, 2024


Related Topics : Array, Math, Geometry, Sorting, Matrix

Acceptance Rate : 71.86 %


Solutions

Python

# I'm sorry this is just funny to me lol

class Solution:
    def allCellsDistOrder(self, rows: int, cols: int, rCenter: int, cCenter: int) -> List[List[int]]:
        return sorted([[x, y] for x in range(0, rows) for y in range(0, cols)], key=lambda x: (abs(x[0] - rCenter) + abs(x[1] - cCenter)))