题解 | #最大间隔#

最大间隔

https://www.nowcoder.com/practice/3a571cdc72264d76820396770a151f90?tpId=182&tqId=34628&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    while(line = await readline()){
    A = await readline();
    maxkk(A);
    }
    function maxkk(A){
    As = A.split(' ');
    Aint = As.map(Number);
    res = new Array;
    len = Aint.length;
    for(let i=0; i<len-1; i++){
        res.push(Aint[i+1]-Aint[i]);
    }
    let max=0;
    for(let i=0; i<res.length; i++){
        max=Math.max(max, res[i]);
    }
    console.log(max);
    }
}()

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务