Challenge: Linear Algebra Foundations #2 – Matrix Subtraction
Subdomeniu: Linear Algebra Foundations (linear-algebra-foundations)
Scor cont: 2.0 / 2
Submission status: Accepted
Submission score: 1.0
Submission ID: 464716572
Limbaj: java8
Link challenge: https://www.hackerrank.com/challenges/linear-algebra-foundations-1-matrix-subtraction/problem
Cerinta
**Matrix Subtraction**
A matrix of size 3x3 is subtracted from another of a similar size. Find the integers $A$, $B$, $C$, $D$, $E$, $F$, $G$, $H$, $I$ in the resultant matrix.
[1 2 3 ] [4 5 6 ] [A B C]
[2 3 4 ] - [7 8 9 ] = [D E F]
[1 1 1 ] [4 5 0 ] [G H I]
In the text box below, enter each of the 9 integers, $A$, $B$, $C$, ... $I$ on a new line.
Cod sursa
public class Solution {
public static void main(String[] args) {
int[][] M = {{1, 2, 3}, {2, 3, 4}, {1, 1, 1}};
int[][] N = {{4, 5, 6}, {7, 8, 9}, {4, 5, 0}};
for (int i = 0; i < M.length; i++) {
for (int j = 0; j < M[i].length; j++) {
System.out.println(M[i][j] - N[i][j]);
}
}
}
}
HackerRank Linear Algebra Foundations – Linear Algebra Foundations #2 – Matrix Subtraction
