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 is elegant and clear.
But if the list is very large or if k is very large, this gets out of hand pretty quickly.
I believe the time complexity of finding all combinations is O(n^min{k, n - k}).
So if ls.len() is 1000 and k is 3, we have O(n^997) which is completely unmanageable.
I ran this on my computer vs a recursive approach,
with 1000 elements and k = 3, your algorithm took 4.13 seconds, while recursive algorithm took 0.12 seconds.
With 10,000 elements and k = 3, your algorithm took 1.25 HOURS, while recursive took 113.65 seconds.
Please consider efficiency when voting for "Best Practices". I don't mean to disparage your code -- it really is beautiful and easy to read. But it is very inefficient.
A very elegant solution. Nice work
very hard to read
Really nice! I wouldn't have thought to do it that way, very smart.
This passes over the string multiple times (each time
matches
is called). DGolubets's solution is more efficientThis comment is hidden because it contains spoiler information about the solution
A little easy for a 4 kyu maybe? I can see this being a solid 5 kyu though.
This was my second try. I did it from memory trying to recreate the top-rated solution because my first attempt wasn't great. Took me a while but I got it!
I'm wondering if you could explain how you got to this answer algebraically? I spent all day on it, looking at various patterns, and eventually had to give up. There's only 3 solutions to this kata, so I'm wondering if maybe it should be considered more difficult.
If I wanted to learn how to do this kind of problem better, what mathematical concepts would I need to familiarize myself with?
Very beautifully written, and easy to follow. I can learn a lot from your solutions and clarity.
Really readable and beautiful code. Nice work!
Short, but difficult to read. What if you used more descriptive variable names, and decompressed the "winner?" block?
This was an interesting kata. I promised myself I wouldn't brute-force it
This comment is hidden because it contains spoiler information about the solution
Very elegant! Nice work
Loading more items...