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.
@Jack-Hogerhuis: because it just creates an array while it is not necessary. The
Reverse()
method works on the string as well, no need to make it (copy it) to a char array first.What I meant with my comment is just pure information: using O(N * logN) sorting is slower and that's it. Maybe I shouldn't have written "horrible".
In most business applications where a code is not in hot path (read: inside of a tight loop), performance difference like this does not matter, and I never wrote it does.
So my important point is that my comment never said a sorting solution is bad, I only sad it has worse performance and for many cases it is fine, but I wanted for people to be aware of this.
To give another perspective for this: in katas on this site, business context are usually not mentioned, so we wouldn't know what constraints should we program to, so we wouldn't know if a solution would be running on a performance-critical system or just a hello world application, so both concise lazy solutions and high-performance solutions and ideas should be supported for the sake of learning.
People basically downvoted my informative comment which is not lying and giving further information to the learner...
By the way, thanks for quasi-proving my point.
Writing a reply since people greatly downvoted my comment.
For those downvoting, I have a small note: compare the runtime performance of a modified minimum selection algorithm and the best sorting algorithm for this scenario...
This comment is hidden because it contains spoiler information about the solution
@jamescurran:
I rephrased my comment to be simpler and more precise.
Indeed, but it is rarely needed to be able to handle real infinity.
The description says: "Create a simple calculator that given a string of operators (+ - * and /) and numbers separated by spaces returns the value of that expression"
But C# test cases contain input without proper spacing.
This is infuriating!
This comment is hidden because it contains spoiler information about the solution
Badly formatted, not very readable code, but clever and efficient.
(The naming guideline for locals is
camelCase
, notsnake_case
.)This solution (while it does the job) is inefficient, since sorting is unnecessary.
A min-index searching algorithm is better fitting here which is O(N) compared to sorting which is at least O(N * log(N)).
This comment is hidden because it contains spoiler information about the solution
Discussion session is not about copy-pasting your own code, please do not do that next time!
Watch the other solution, this is not the best.
This comment is hidden because it contains spoiler information about the solution
Creative solution; however I feel an overkill to use a Queue for this simple task.
My vote as "Clever" :-)
Loading more items...