Skip to content

Commit 070edcd

Browse files
authored
Create 3643. Flip Square Submatrix Vertically.py
1 parent 3f989a5 commit 070edcd

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
범위의 위쪽 row, 아래쪽 row의 인덱스를 찾아서 바꿔줍니다.
6+
7+
2. 시간복잡도 :
8+
O(n*n)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def reverseSubmatrix(self, grid: List[List[int]], x: int, y: int, k: int) -> List[List[int]]:
16+
for row in range(x, x+k//2):
17+
for col in range(y, y+k):
18+
grid[row][col], grid[2 * x + k - 1 - row][col] = grid[2 * x + k - 1 - row][col], grid[row][col]
19+
return grid
20+

0 commit comments

Comments
 (0)