I'm on another codewar problem here
https://www.codewars.com/kata/54521e9ec8e60bc4de000d6c/train/java
The problem is to find the subset of continuous values which adds up to being the highest value. The example here is
So the values 4, -1, 2, 1 add up to be the highest value which is 6.
If the int array is all positive then just add up the entire array.
If all negative values then return 0.
If it's an empty array return 0
I think I understand an all positive array, an all negative and an empty. I figure I would iterate over and
test the values as to whether they are all over 0 , all under 0 or empty but if there is a mix of values I'm a bit stumped as to what the best solution is.
I keep thinking of ways that I maybe able to solve this when there is a combination of both positive and negative numbers but most of them seem complicated and most likely NOT the correct way . Is there any tips someone can give me as to what maybe the best solution?
On paper I can come up with a few ideas but none seem ideal or when I test the idea I see an issue with it.