#3643

Flip Square Submatrix Vertically

easy · 72.9% accepted · 56 likes · top 83%

array · two pointers · matrix

Description

You are given an m x n integer matrix grid, and three integers x, y, and k.

The integers x and y represent the row and column indices of the top-left corner of a square submatrix and the integer k represents the size (side length) of the square submatrix.

Your task is to flip the submatrix by reversing the order of its rows vertically.

Return the updated matrix.

Solution