From 744b5ac4312f5c0cacaefaa4c1b12ba0716dd23d Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Fri, 5 Dec 2025 10:53:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Product=20of=20Array=20Except=20Self=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product-of-array-except-self/ymir0804.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 product-of-array-except-self/ymir0804.java diff --git a/product-of-array-except-self/ymir0804.java b/product-of-array-except-self/ymir0804.java new file mode 100644 index 0000000000..1f28eae1d4 --- /dev/null +++ b/product-of-array-except-self/ymir0804.java @@ -0,0 +1,15 @@ +class Solution { + public int[] productExceptSelf(int[] nums) { + int [] result = new int [nums.length]; + result[0] = 1; + for (int i = 1; i < nums.length; i++) { + result[i] = result[i - 1] * nums[i - 1]; + } + int suffixProduct = 1; + for (int i = nums.length - 1; i >= 0; i--) { + result[i] *= suffixProduct; + suffixProduct *= nums[i]; + } + return result; + } +} From 08b539e136977fea4182eb0a02cff2e8d0bc7fd6 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Fri, 5 Dec 2025 10:56:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?lint=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product-of-array-except-self/ymir0804.java | 1 + 1 file changed, 1 insertion(+) diff --git a/product-of-array-except-self/ymir0804.java b/product-of-array-except-self/ymir0804.java index 1f28eae1d4..25dad13a54 100644 --- a/product-of-array-except-self/ymir0804.java +++ b/product-of-array-except-self/ymir0804.java @@ -13,3 +13,4 @@ public int[] productExceptSelf(int[] nums) { return result; } } +