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 comment is hidden because it contains spoiler information about the solution
Have you actually tried testing that claim? I've tested 5 solutions (mine, the linq solution commented on, yours and two others from this comment thread). Only one commenter I tested in this thread (zokeer) has a solution that actually runs faster than the Linq solutions (though at least all the solutions run in linear time against varying string lengths and varying unique character amounts). Both yours and Zub_Son's are slower than the Linq solutions despite commenting on the alleged slowness of it.
Not only are the Linq solutions easier to write and read, this shows that most people trying to make faster/more optimized solutions end up slower than the naive Linq one. Add in that such optimizations aren't really necessary unless the method is an a hot path and I'll prefer a competently written short Linq solution 90% of the time.
Both your and this solution run in linear time, so I'm not sure why you'd think this is inefficient in terms O-Notation. Your solution is roughly two times faster than both this and my Linq solution in my tests (string length of 650, 6500 and 65000) but all three solutions scale linearly. The Linq solutions also allocate more space but unless this function represents a performance bottleneck I would 100% prefer a short and easy to read/write Linq expression over doing it by hand.
This comment is hidden because it contains spoiler information about the solution
This can't really be best practice with how many extra strings get unnecessarily created with each recursive call.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Rust translation!
Still, one of sentences suggests the stronger requirement: "[...] find out whether the cuboid has equal sides (= is a cube)".
EDIT: okay I see you updated it.
It doesn't say if it is a cube it says if it could be:
And that has already been mentioned here: https://www.codewars.com/kata/58d248c7012397a81800005c/discuss#642de3f56555a387e8795e45
Anyways, I've changed the description to replace
has
and=
forcould have
andcould be
.This comment is hidden because it contains spoiler information about the solution
And All stops after the first mismatch. Both perform the same here.
The point is that it's bad practice to mutate input. Undocumented side effects like that are hell on readability.
Loading more items...