```
public int[] productExceptSelf(int[] nums) {
int[] rs = new int[nums.length];
if (nums.length <= 1) {
return rs;
}
rs[0] = nums[1];
rs[1] = nums[0];
for (int i = 2; i < nums.length; i++) {
rs[i] = rs[i-1] * nums[i-1];
for(int j=0; j<i; j++){
rs[j] *= nums[i];
}
}
return rs;
}
```