• + 5 comments

    Guys we also have one more alternative, with the help of flag we can achieve it,

    if (flag) {

    max = sum;

    flag = false;

    }

    if (max < sum) {

    max = sum;

    }