【书上的题解真妙】
public class Solution { public int[] multiply(int[] A) { if (A == null || A.length <= 0) { return null; } int[] C = new int[A.length]; C[0] = 1; for (int i = 1; i < C.length; i++) { C[i] = C[i - 1] * A[i - 1]; } int[] D = new int[A.length]; D[D.length - 1] = 1; for (int i = D.length - 2; i >= 0; i--) { D[i] = D[i + 1] * A[i + 1]; } int[] result = new int[A.length]; for (int i = 0; i < result.length; i++) { result[i] = C[i] * D[i]; } return result; } }