Answers for "pair of adjacent elements javascript"

0

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

function adjacentElementsProduct(inputArray) {
    var cb = Number.NEGATIVE_INFINITY;
    for(var i=0;i<inputArray.length-1;i++){
        if(inputArray[i]*inputArray[i+1] > cb){
          cb = inputArray[i]*inputArray[i+1];
        }
    }
  return cb;
}
Posted by: Guest on November-26-2019
0

pair of adjacent elements javascript

10 9 13 15 3 16 9 1
Posted by: Guest on October-18-2021

Code answers related to "pair of adjacent elements javascript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language