We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b24489 commit c8d979aCopy full SHA for c8d979a
product-of-array-except-self/std-freejia.java
@@ -0,0 +1,23 @@
1
+class Solution {
2
+ public int[] productExceptSelf(int[] nums) {
3
+ int len = nums.length;
4
+ int[] res = new int[len];
5
+ int num = 1;
6
+
7
+ for (int i = 0; i < len; i++) {
8
+ res[i] = num;
9
+ num *= nums[i];
10
+ }
11
+ num = 1;
12
+ for (int i = len -1; i>=0; i--) {
13
+ res[i] *= num;
14
15
16
17
18
+ System.out.print( res[i] + " ");
19
20
21
+ return res;
22
+}
23
0 commit comments