Diagonal Difference

  • + 1 comment

    I don't even bother storing leftD and rightD.

    if(j == k) { result += curInput; }
    if(j+k+1 == numInputs) { result -= curInput; }
    ans = abs(result);