• + 0 comments

    Hint for those who pass all test cases except fail 7, 10, 11, 12 and 16 by which are producing extra numbers and missing small sums:

    Extra sums, credit @boon_low

    • Test case 7 97, 96, 82, 73, 61, 57, 51, 29, 29, 24, 18, 14, 11
    • Test case 10 129, 127, 91, 79, 79, 70, 68, 62, 60, 48, 38, 29, 20, 11, 10
    • Test case 16 136, 126, 99, 93, 53, 49, 49

    My problem was using a left-folding implementation of Kadane's algorithm instead of a right-folding one.

    Consider this, credit @t0mpr1c3

    5 3
    1 -1 999 -2 2
    

    What is the correct answer?

    I thought it was 999, 2, 1 for hours, but the actual correct answer is 999, 2.