For [1,2,3,4] style array length 6, print products without division.
Toolliyo Coach
Progressive help: Nudge → Guide → Approach. Full solution stays behind the Solution tab.
Editor is open — no login wall to practice.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] a = { 1, 2, 3, 4, 5, 6 };
int len = a.Length;
int[] outArr = new int[len];
outArr[0] = 1;
for (int j = 1; j < len; j++) outArr[j] = outArr[j - 1] * a[j - 1];
int suffix = 1;
for (int j = len - 1; j >= 0; j--) { outArr[j] *= suffix; suffix *= a[j]; }
Console.WriteLine(string.Join(" ", outArr));
}
}
Prefer Coach (Nudge → Guide → Approach) before revealing. No forced signup.
Prefix + suffix products.
Sign in to save and review your submission history. You can still Run code on the Editor tab as a guest.
Sign in