Sorting just to take the min or max is inefficient. This is O(n log n) instead of O(n).
True that it is negligible but since they asked: the ternary is more efficient.
In general, operators are ever so slightly faster than function calls.
but They did not ask to change the current string , if they wnat to change it then there is no need for reterned
value .. other wize is to create a new string make a change of it and return a copy of it ..
you also don't need to check for even numbers (except 2)
This is why I love codewars! I never would have found about about this.
Does this only work with GNU compilers?
good time complexity on this one, think it's optimal
Uh, is that legal? ))
The point of the task is to use RegExp.
From performance point of view, is deque better than just reverse sorted list?
Slight modification though, we shoudn't be ovveriding parameters
It doesn't change the question at all. Whether you pass an lvalue by const& or not doesn't change the behavior, as both value categories can bind to anything. On top of that, look at the return type of the function.
Finally a O(n) solution in the top solutions of this kata :)
Haha, skipped comparison with 'a'. And really, task restrictions says that string is always in range from 'a'.
Why using range with n+1 when rangeClosed includes the last value in the IntStream?
good joab man