educative.io

How to make DP solution work with negative numbers?

Running the bottom-up solution on input {1,-1,0,4,-2,-9} results in a NegativeArraySizeException.


Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/5390739594805248

Hey Matthew_Huynh!
The problem statement is for positive numbers. That’s why the solution is throwing NegativeArraySizeException.
We hope Educative has inspired you to further your learning. Thank you for asking the question.