You are viewing a single comment's thread. Return to all comments →
function main() { const n = parseInt(readLine().trim(), 10); const arr = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10)); let maxDiff = 0; let diff = 0; for (let i = 0; i < n-1; i++) { for (let j = i+1; j < n; j++){ diff = Math.abs(arr[i] - arr[j]); if (diff > maxDiff) maxDiff = diff; } } console.log(maxDiff); }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 14: Scope
You are viewing a single comment's thread. Return to all comments →
My JavaScript Solution