From 197958fe0bfc382eb8d5d26b159c49b75bbf33ec Mon Sep 17 00:00:00 2001 From: Yucheng Hu Date: Sat, 15 Dec 2018 14:25:17 -0500 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=82=B9=E7=A7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lintcode/LintCode1480DotProductTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java b/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java new file mode 100644 index 0000000..e4ab235 --- /dev/null +++ b/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java @@ -0,0 +1,49 @@ +package com.ossez.lang.tutorial.tests.lintcode; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 1480 + *

+ *

+ * + * @author YuCheng + * + */ +public class LintCode1480DotProductTest { + + private final static Logger logger = LoggerFactory.getLogger(LintCode1480DotProductTest.class); + + /** + * + */ + @Test + public void testMain() { + logger.debug("BEGIN"); + int[] A = { 1, 1, -1 }; + int[] B = { 2147483647, 1, 3 }; + + 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); + } + +}