You are given an m × n integer matrix matrix, and three integers r, c, and size.
• r and c represent the row and column indices of the top-left corner of a square submatrix.
• size represents the side length of the square submatrix.
Your task is to reverse the square submatrix vertically, i.e., flip its rows top to bottom while keeping the rest of the matrix unchanged.
Return the updated matrix after performing this operation.
Input: matrix = [ [10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21], [22, 23, 24, 25] ] r = 0 c = 1 size = 3
Output: [[10,19,20,21],[14,15,16,17],[18,11,12,13],[22,23,24,25]]
Input: matrix = [ [5, 6, 7], [8, 9, 10], [11, 12, 13], [14, 15, 16] ] r = 1 c = 0 size = 2
Output: [ [5, 6, 7], [11, 12, 10], [8, 9, 13], [14, 15, 16] ]
Accepted:
Submission: