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.
This. Otherwise it looked good to me.
1st rule of TDD: the spec is practically defined by the tests, not how the description is written. If the tests simply allow any code to pass, then there are practically no specs, so of course the blame goes to the kata author of writing a dubious test fixture ;-)
If you claim that something has to be done in a particular way, then your tests should ensure that the requirements are met. Otherwise, the design is simply bad.
The author should write tests which won't allow inefficient solution passing - there's no other way around.
Well, in general katas about basic interview questions (or problems which source can be easily googled with answer directly read from there) are not very good kata ideas because
I typically raise an issue about the 3rd point if I happen to find the exact source because attributions are important.
Though in this case, the downvotes mostly come from the
O(1)
requirement not being enforced at all. It's up to the kata author to make sure everything works and there are full test coverage before publishing ;-) If it gets retired, rework on the kata again and try again, but if the idea itself is not very interesting to begin with, the second try might not be very successful either.