P21789 [GeeksforGeeks] Addition of two square matrices4916
普及-
题目描述

Given two square matrices matrixA and matrixB of size n x n. Find the addition of these two matrices.
Note :- You don't have to return anything in this question (Refer YourTask section).

Example 1:
Input: matrixA = {{1, 2}, {3, 4}},
matrixB = {{4, 3}, {2, 1}}
Output: {{5, 5}, {5, 5}}
Example 1:
Input: matrixA = {{2, 2}, {2, 2}},
matrixB = {{3, 3}, {3, 3}}
Output: {{5, 5},{5, 5}}

Your Task:
You don't need to read or print anything. Your task is to complete the function Addition() which takes matrixA and matrixB as input parameters and adds two matrices. Do the addition without using extra memory. The output matrix must be in matrixA.

Expected Time Complexity: O(n^{2})
Expected Space Complexity: O(1)

Constraints:
1 <= n <= 100

输入格式

见题面

输出格式

见题面

样例输入
matrixA = {{1, 2}, {3, 4}}, matrixB = {{4, 3}, {2, 1}}
样例输出
{{5, 5}, {5, 5}}