Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5e1304e

Browse files
Create Flip Square Submatrix Vertically.java
1 parent 8aa5b55 commit 5e1304e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public int[][] reverseSubmatrix(int[][] grid, int x, int y, int k) {
3+
for (int j = y; j < y + k; j++) {
4+
int top = x;
5+
int bottom = x + k - 1;
6+
while (top < bottom) {
7+
int temp = grid[top][j];
8+
grid[top][j] = grid[bottom][j];
9+
grid[bottom][j] = temp;
10+
top++;
11+
bottom--;
12+
}
13+
}
14+
return grid;
15+
}
16+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /