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 great, I could not reason about how to effectively use fold here, building the number up by shifting the previous value makes a ton of sense.
It's easy to understand and code is clean, that's why it's the best solution.
Wow, very clever. Took some thinking to understand what you did here, but fun solution!
I think iterating on the positions while removing them means you are skipping some removals in each pass. Consider if you remove entries 0, 1, 2 on the first pass, you'll be pointing 4 items further than you want after that.
Agreed, the inconsistent return types is a bad recommendation for newbies.
Agreed, I initially implemented a recursive function (in C++) and had to back away from it because of the strange edge case.
This comment is hidden because it contains spoiler information about the solution
'm n ttl grmnt wth ths cmmnt!
You can iterate directly on characters, avoiding the
char znak
and assigningi
to it, like so:Hope that helps!
My original solution did use a SortedSet, but I could not get it to be performant (did not know about first()/pollFirst()), so I went down to using actual bit math. I suspect this is the most performant option. It doesn't include the early exit for when u.size>y that my original solution had, either, so it could probably be faster.