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.
Incorrect solutions can pass if you try the tests a few times. My solution failed a few test cases; I inserted a print statement to display the inputs, ran it again, and it passed!
lgtm, approved
F___! Fixed.
Did the other.
Added message showing the array length.
Thanks for the review.
In the assertion message.
Also you only replaced one of the
random.nextInt(2)
calls.Oh and your refsol is public, you can literally just
return LargestSumTest.getExpected(array);
to pass all the tests. Refsol should always be private at a minimum.Changed.
I added another zero to the large random tests. This causes the following to time out.
for (int i = 0; i < array.length-1; i++) {
sum = 0;
for (int j = i; j < array.length; j++) {
sum+=array[j];
if (sum > maxSum) maxSum = sum;
}
}
In the description? Or in some other way?
Two things:
random.nextInt(2) == 0
=>random.nextBoolean()
Also, you did check that perf tests don't pass with naive solutions, right? 36ms on the sample output looks sus.
Loop through the tree, comparing each node to the sum of its children. When you find a mismatch, you have to figure out which is the wrong value. This can be done by considering different cases. For example, is either of the children not equal to the sum of its children?
Question: In the example ([-2, -1, 1, 2]) ➞ [-2, -1, 1, 2], why don't the -1 and 1 meet and destroy each other?
Hey guys can you give me some hints on how to solve this problem
Duplicate?
My first attempt failed two of the fixed tests:
'\n.'
and'..\n\n..'
. But it passed all the random tests. So I just had to hardcode those two cases. The random tests should include examples like those. In that case solutions like mine would have to be correctly fixed.Fun problem, although a little easy for 5kyu.
One suggestion: It would be nice if an example showing multiple lines was included in either the description or the sample tests.
During the beta the average vote was 7kuy, and there was even a 6kyu.
There are 171 stars, even if it's easier to solve the kata than to click over the star icon.
this is problably the easiest problem i will ever have lol
Loading more items...