```
public int[] productExceptSelf(int[] nums) {
int n = nums.length, i;
int[] result = new int[n];
int cur = 1;
for (i=0;i<n;i++) {
result[i] = cur;
cur *= nums[i];
}
cur = 1;
for (i=n-1;i>=0;i--) {
result[i] *= cur;
cur *= nums[i];
}
return result;
}
}
```