Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.
Answers
Answered by
0
Answer:
- Define a variable t to store the largest product and set it equal to the product of the first 2 elements of the array.
- Using a for loop, loop through the elements of the array
- At the i-th iteration, check whether array[i-1] *array[i] > t.
- If True : set t = array[i-1] *array[i]
- If False : continue looping
- The final value of t is the largest product.
Similar questions