일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- Python Code
- 315. Count of Smaller Numbers After Self
- DWG
- 프로그래머스
- Python
- Class
- Protocol
- Convert Sorted List to Binary Search Tree
- concurrency
- Decorator
- 파이썬
- 밴픽
- LeetCode
- data science
- 30. Substring with Concatenation of All Words
- kaggle
- Regular Expression
- 컴퓨터의 구조
- 운영체제
- 715. Range Module
- 43. Multiply Strings
- Python Implementation
- 시바견
- shiba
- Substring with Concatenation of All Words
- attribute
- Generator
- t1
- 109. Convert Sorted List to Binary Search Tree
- iterator
Archives
- Today
- Total
Scribbling
LeetCode: 1329. Sort the Matrix Diagonally 본문
Computer Science/Coding Test
LeetCode: 1329. Sort the Matrix Diagonally
focalpoint 2021. 11. 24. 14:45class Solution:
def diagonalSort(self, mat: List[List[int]]) -> List[List[int]]:
m, n = len(mat), len(mat[0])
starting_points = [(0, i) for i in range(n)] + [(i, 0) for i in range(1, m)]
for starting_point in starting_points:
array = []
y, x = starting_point
while y <= m - 1 and x <= n - 1:
array.append(mat[y][x])
y += 1
x += 1
array.sort()
y, x = starting_point
for val in array:
mat[y][x] = val
y += 1
x += 1
return mat
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 150. Evaluate Reverse Polish Notation (0) | 2021.11.26 |
---|---|
LeetCode: 238. Product of Array Except Self (0) | 2021.11.25 |
LeetCode: 1466. Reorder Routes to Make All Paths Lead to the City Zero (0) | 2021.11.23 |
LeetCode: 149. Max Points on a Line (0) | 2021.11.22 |
LeetCode: 143. Reorder List (0) | 2021.11.22 |