Ad
  • Custom User Avatar
  • Custom User Avatar

    yeah I would have gone about it differently if they included a statement about not modifying the signature

  • Custom User Avatar

    That's interesting.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You are right and you should mark your reply as ISSUE because it is surely broken. In the example which you have posted I hace found this as the greatest sum subsequence [13, -2, 25, 21, 29, 23, -7, -8, 22, 14, 23, -23, 11, 25, 30, 14] whichhives sum of 210. And 0 should be returned only if the list is made up of only negative numbers or is empty.

  • Custom User Avatar

    Because [4, -1, 2, 1] is the subsequence with the greatest sum (6) in [-2, 1, -3, 4, -1, 2, 1, -5, 4].

    Any other subsequenc would have lower sum than that for example

    • [4, -1, 2, 1, -5] sums up to 1
    • [-3, 4, -1, 2, 1] sums up to 3
    • [1, -3, 4] sums up to 2
    • [1, -3, 4, -1, 2, 1] sums up to 4

    So you have to find the subsequence of any length that produces the greatest sum.

  • Custom User Avatar

    You have probably wrong condition for handling input value and you are throwing extra Exceptions when it is not intended.

    That was my problem - I've looked up the condition and turned out that in one extra case I threw an exception.