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