SOURCE

function dis(arr){
    let cur = arr[1] - arr[0]
    let max = cur
    for(let i = 0; i < arr.length; i++) {
        for(let k = i + 1; k < arr.length; k++) {
            cur = Math.max(cur, arr[k] -arr[i])
            max = Math.max(cur,max)
        }
    }
    return max
}

console.log(dis(
    [5,4,17]
))
console 命令行工具 X clear

                    
>
console