public static void Main()
Console.WriteLine(string.Join(",", ProductExceptSelf(new int[]{1,2,3,4})));
Console.WriteLine(string.Join(",", ProductExceptSelf(new int[]{4, 5, 1, 8, 2, 10, 6})));
Console.WriteLine(string.Join(",", ProductExceptSelf2(new int[]{1,2,3,4})));
Console.WriteLine(string.Join(",", ProductExceptSelf2(new int[]{4, 5, 1, 8, 2, 10, 6})));
private static int[] ProductExceptSelf(int[] nums)
int[] l2R = new int[len];
for(int i = 1; i < len; i++)
l2R[i] = l2R[i - 1] * nums[i - 1];
for(int i = len - 1; i >= 0; i--)
private static int[] ProductExceptSelf2(int[] nums) {
int[] l2R = new int[len];
int[] r2L = new int[len];
for(int i = 1; i < len; i++)
l2R[i] = nums[i - 1] * l2R[i - 1];
for(int i = len - 2; i >= 0; i--)
r2L[i] = nums[i + 1] * r2L[i + 1];
for(int i = 0; i < len; i++)
l2R[i] = l2R[i] * r2L[i];