计算点积
This commit is contained in:
parent
21204ebbc1
commit
4ec06517c0
|
@ -27,9 +27,23 @@ public class LintCode1480DotProductTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMain() {
|
public void testMain() {
|
||||||
logger.debug("BEGIN");
|
logger.debug("BEGIN");
|
||||||
int t = 87;
|
int[] A = { 1, 1, -1 };
|
||||||
int[] dur = { 20, 25, 19, 37 };
|
int[] B = { 2147483647, 1, 3 };
|
||||||
// Write your code here
|
|
||||||
|
int retStatus = 0;
|
||||||
|
|
||||||
|
// LENGTH CHECK
|
||||||
|
if (A.length == 0 || B.length == 0 || A.length != B.length)
|
||||||
|
retStatus = -1;
|
||||||
|
|
||||||
|
// ADDED
|
||||||
|
if (retStatus != -1) {
|
||||||
|
for (int i = 0; i < A.length; i++) {
|
||||||
|
retStatus = retStatus + A[i] * B[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(retStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue