AlgoDaily Solution
1Locked, only available for premium members.
Community Solutions
Community solutions are only available for premium users.
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.
xxxxxxxxxx
36
var assert = require('assert');
function maximumDistance(arr, n) {
// Your code here
}
try {
let myArr = [10, 20, 30, 40];
n = myArr.length;
assertIsFunction(maximumDistance);
assert.equal(maximumDistance(myArr, n), 33);
console.log(
'PASSED: ' + '`maximumDistance([ 10, 20, 30, 40 ], 4)` should return `33`.'
);
} catch (err) {
console.log(err);
}
try {
let myArr = [-70, -64, -6, -56, 64, 61, -57, 16, 48, -98];
n = myArr.length;
assertIsFunction(maximumDistance);
assert.equal(maximumDistance(myArr, n), 167);
console.log(
'PASSED: `maximumDistance([ -70, -64, -6, -56, 64, 61, -57, 16, 48, -98 ], 10)` should return `167`.'
OUTPUT
Results will appear here.