• + 1 comment

    selectig the smallest top of stack from a, and b doesn't always guarantee the maxmum number of selections. I know this seems counter-intuitive but consider the following example: maxSum = 10 a = [5, 6] b = [6, 4]

    The correct answer is 2 selections (b[0] + b[1] = 6 + 4 = 10). But you code will produce only 1 selection (a[0] = 5).

    • + 0 comments

      Nice one