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
This comment is hidden because it contains spoiler information about the solution
In fact, this will need to be done in any case, even if it is the first method call. In the worst case scenario where the searched element is the last, this will not be very good for large volumes of data, as was indicated in the condition
If you look at it from a performance point of view, this solution will benefit when compared with a solution that uses Sequence. During my research, Sequence takes between 5 and 13 seconds, while a solution based on while takes 0 seconds
It certainly looks elegant and functional, but I dug deeper into how Sequence works and how effective they are for small sets or sequences. As a result, using the measureTimeMillis function, I found that executing generateSequence with subsequent processing takes from 5 to 13 seconds. While if you use "do{}while(...)" or just "while" it takes 0 seconds. From this we can conclude that although Sequence is very concise and saves us from mutability and temporary variables, we still need to be careful when using them for such tasks.
I think this is clever but definitely not best practice.