Compute sums of remaining windows by removing first element of previous window and adding last element of current window
int curr_sum = res ; for ( int i = K ; i < N ; i ++ ) { curr_sum += arr [ i ] - arr [ i - K ] ; res = max ( res , curr_sum ) ; }