Computer Science, asked by mustafaalbudairi, 9 hours ago

Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.

Answers

Answered by BetaDecay
0

Answer:

  1. Define a variable t to store the largest product and set it equal to the product of the first 2 elements of the array.
  2. Using a for loop, loop through the elements of the array
  3. At the i-th iteration, check whether array[i-1] *array[i] > t.
  4. If True : set t = array[i-1] *array[i]
  5. If False : continue looping
  6. The final value of t is the largest product.

Similar questions