/**
*
* Ashish Patel
* e: ashishsushilPatel@gmail.com
* w: https://ashish.me
*
*/
function pairwiseArrayComparisons(array) {
let maxDelta = Math.abs(array[0] - array[1])
for (let index = 0; index < array.length; index++) {
const delta = Math.abs(array[index] - array[index + 1]);
if(delta > maxDelta){
maxDelta = delta
}
}
return maxDelta
}
test('pairwise Array Comparisons', () => {
expect(pairwiseArrayComparisons([70, 72, 68, 65, 74, 74, 73])).toEqual(9)
});
Created 2019-11-29T03:25:56+05:30, updated 2019-11-30T02:28:17+05:30 · History · Edit