loading...

re: Daily Coding Problem #2 VIEW POST

FULL DISCUSSION
 

Don't know if the use of Parallel.ForEach is legit, but here's my take using C# and Linq

static void DoWork(int[] original)
{
   var res = new int[original.Length];
   for (int i = 0; i < original.Count(); i++)
   {
      var notCurrent = original.Where(x => x != original[i]);
      int sum = 1;
      Parallel.ForEach(notCurrent, (notI)=>{ sum = sum*notI;});
      res[i]= sum;
    }
}

Code of Conduct Report abuse