Mini max sum Hackerrank solution in c, c++, python , java