15 February 2017

adjacentElementsProduct

My solution:
int adjacentElementsProduct(int[] inputArray) 
{
    int largest_product = int.MinValue;
    for (int i = 0; i < inputArray.Length - 1; i++)
        if (inputArray[i] * inputArray[i + 1] > largest_product)
            largest_product = inputArray[i] * inputArray[i + 1];

    return largest_product;
}

Previous Next