prefix sum
-
[array] product of array except selfAlgorithm/LeetCode 2025. 2. 8. 17:46
✅ Problemhttps://leetcode.com/problems/product-of-array-except-self/ ✅ Approach & Solution방식1) 시간복잡도 : O(n)더보기자기 자신을 제외하고 자신의 왼쪽 곱셈 결과와 오른쪽 곱셈 결과 곱하기class Solution { public int[] productExceptSelf(int[] nums) { int[] result = new int[nums.length]; // 자기 자신의 왼쪽 곱셈 결과 포함시키기 int p = 1; // 자기 자신은 제외시켜야 하므로 1로 초기화 for (int i = 0; i = 0; i--) { result[i] *= p;..