Friday, November 23, 2012

Given an array of integers, populate another array with the product of the elements of the first array except for the current index element.

1 comment:

  1. int prod = 0;
    foreach(int i : vector) prod *= i;

    for (int idx = 0; idx < N; ++idx) {
    vector[idx] = prod/vector[idx];
    }

    ReplyDelete