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.
Such a cool problem. I learned a lot of new stuff about Stream.
You can do this kind of comment in your own solution, marking your post as having spoiler content there too.
This comment is hidden because it contains spoiler information about the solution
This can be solved using recursive algorithm but apparently people think that's the best practice. It is clever for sure but performance-wise, I regular loop beats it.
Please, don't post solutions. It's forbidden.
This comment is hidden because it contains spoiler information about the solution
there is a one-liner solution for this using stream, not sure if it is the best practice or the best solution performance-wise, but it is definitely readable and clean.