Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks so much! I understood my mistake and my solution is correct now! Finally I did it!
Your solution fails following tes cases:
(Java) Hello! I have unpassed test here: "Index 29 out of bounds for length 29". I don't what does it mean and what i have to change. But in IntelliJ Idea my code works every time with any numbers, actually i took numbers with different length. Can someone tell what about this test?
my first question:
sorry, i was meaning how can i define maximum sum if i even don't know what does our array consist of(certain numbers)? And smoothly moving on to the second question we don't know about sum of our subarray and accordingly about length of our subarray. So how can i figure out sum if i don't know number of values my subarray? As i understand we can find out sum if we know number of values of subarray(this is standart algorithm), but we dont't know that.
Yes, once you understand the objective of the kata, you have to come up with an algorithm/program that finds the result yourself!
As always, if you are a bit confused, it is a good idea to try with the given example and use a pen and paper (old school) before trying to write code - how would you solve this kata on paper in "English/words".
For your 2nd question, I don't understand 100% - the "length of the optimum subarray" can range from 0 to L (where L is the size of the input) - for example:
[-3,-6,-1]
-> for this given input, the correct answer for the maximum subarray sum is 0; this occurs when you take the empty subarray[]
with no elements in it (any other subarray would contain a negative number so it would be less than 0)[5,9,100,5,2]
-> for this given input, the correct answer for the maximum subarray sum is 5+9+100+5+2=121, when you take the entire array of length 5.ok, almost full part of task i understood. But how can i find out maximum sum? I have to come up with myself? And how have i to define length of subarray initially?
Hi - you have to find the maximum sum you can make from the given array, by selecting a contiguous (this means, "all side by side in the original array") subarray.
For example:
Can someone tell me what i have to do exactly? I can't figure out which subarray sum i need to calculate.