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.
Yes, those all involve binary search trees, but none of them, as far as I can tell, actually ask you to implement a search through a binary search tree. Can you point to one of these that actually asks the same thing I am?
The default Python code has a tab before
return True
. Codewars' editor defaults to spaces, so keeping the supplied return statement while adding any other edits results in ainconsistent use of tabs and spaces
error.Okay, I have rewritten it to follow common Java practices, accessing fields through getters.
I suppose I can include that if I make some very large random tests that will time out with an O(n) algorithm but not with an O(log n) algorithm.
Sorry, Codewars doesn't seem to have a way to save drafts. Should be fixed now.
A naive approach would be to search through every single node in the tree without regard to the particular properties of binary search trees that make this unnecessary. I include an invalid tree to make sure this is not what the solution is doing. You are right that I should make this clearer in my instructions though.
A naive approach would be to search through every single node in the tree without regard to the particular properties of binary search trees that make this unnecessary. I include an invalid tree to make sure this is not what the solution is doing. You are right that I should make this clearer in my instructions though.
It would be more efficient to use
elif
s here rather than 3if
s, as if an earlierif
is true, later ones won't be.I tried this and it timed out. Probably luck of the draw as to what random tests you get.
This comment is hidden because it contains spoiler information about the solution
It's shorter, but it's a lot less readable.