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.
ok sorry didn't know. Solved anyway. Thank you
Hi mirko06854,
In general, you should avoid posting code. Instead state the language that you submitted in. Then the kata author can view your solution, without other people seeing it. And if you do post code, you should mark it as a spoiler. Otherwise, other people might see it who don't want to!
Also, it would help if you provide some information about what happens when you try your program. For example, do all the sample tests pass? If not, which test fails, and what message do you get? If all the sample tests pass, but the hidden tests do not, then you can insert print statements at the top of your function to print out the values of the input parameters. This can help you see which hidden test fails, and you can probably debug your function yourself.
I hope this helps. If not, post more information about how your program behaves (but not the code itself)!
brodiemark
This comment is hidden because it contains spoiler information about the solution
ok thank you
It can done recursively, though that doesn't seem as natural to me as looping. I think focusing on the different cases that can arise where sum of children doesn't equal node can help figure out a approach.
would is be possible to solve it using recursion and not level order traversal? any tips ? thank you
yes, but you are not calling the push function inside the method buildOneTwoThree()
thanks
Fixed for Java.
numbers = [4, 0, 7, 1, 5] ==> expected: <1> but was: <5>
I think the answer should be 1+4
not 0+1
this is the measleading test
the language is in java.
Try to replace this line of my solution :
if (numbers[i]<0||numbers[i]!=(long) numbers[i])
with
if (numbers[i]<=0||numbers[i]!=(long) numbers[i])
as well as another similar line , and you will see the wrong test
That looks like an error in the tests, mention the language you're talking about, it doesn't happen in javascript.
I think the last test is misleading, the one with zeros.
'0' is neither negative nor positive in Math but you assume it is positive, you should have explicitally state in the instructions in my opinion.
I resoned initially by excluding 0 since it isn't neither positive nor regative