Tap here to switch tabs
Problem
Submissions

Problem: Flip Square Submatrix Vertically

med
30 min
Try to solve the Flip Square Submatrix Vertically problem.

Statement

You are given an m×nm \times n integer matrix grid, along with three integers x, y, and k.

There is a k×kk \times k square submatrix with its top left corner located at row x and column y.

Flip this square submatrix vertically by reversing the order of its rows while keeping the columns unchanged.

Return the modified grid.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \le m, n ≤50\le 50

  • 1≤1 \le grid[i][j] ≤100\le 100

  • 0≤0 \le x << m

  • 0≤0 \le y << n

  • 1≤1 \le k ≤min⁡(\le \min(m −- x, n −- y))

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Flip Square Submatrix Vertically

med
30 min
Try to solve the Flip Square Submatrix Vertically problem.

Statement

You are given an m×nm \times n integer matrix grid, along with three integers x, y, and k.

There is a k×kk \times k square submatrix with its top left corner located at row x and column y.

Flip this square submatrix vertically by reversing the order of its rows while keeping the columns unchanged.

Return the modified grid.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \le m, n ≤50\le 50

  • 1≤1 \le grid[i][j] ≤100\le 100

  • 0≤0 \le x << m

  • 0≤0 \le y << n

  • 1≤1 \le k ≤min⁡(\le \min(m −- x, n −- y))