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.
Not possible, because 'x' takes the first element of (sorted) queue.
But the list 'u' is not needed : never read except his size. Maintains a counter or decreasing 'n' will be enougth
And why in the hell a check is done on queue in loop condition, it grows constantly (2 add for 1 remove)
Summary : "while(true){...}" + "if(n--==0) return x;" instead of "u.Add(x);"
Except the gready pitfall, it's nice and clever
Hi,
Too late for that, unfortunately. Closing.
Please make requests on CW github instead of this page.
Which would be more efficent?
1.Sortedset + List
2.Hashset + List with sort() at the end before returning
Just wondering.
Same!I mean, the description is a little deceptive about that lol.
Edit: Then I realized you have to remove the duplicate .. oops?
For c# and some other similar language: The key should be of 'char' type instead of 'string' since there is only 1 letter.
Apparently this was because of try-catch statement. The "throw" has to be outside the statement, which should have been stated more clearly...
This comment is hidden because it contains spoiler information about the solution
For c#: Should the solution be cleaner if there is a way to enable and use unsafe code.
Can you add a way to run c#'s unsafe code? Apparently there is option to do that on codewars. Thanks.