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.
Very smart
This solution is very simple but it's also n^2 complexity, you can do better :)
Ah yeah, my bad. Forgot to click it.
Please use spoiler flag next time. Your post was visible in the homepage.
This comment is hidden because it contains spoiler information about the solution
u could use erase(remove_if(...),end());
HOW???
Is it possible that the erase() function will unnecessarily increase resource and time usage? Every time an erase operation occurs, given that the string is an array, a whole new region is reserved in memory and the contents of the existing string must be moved each time, except for the erased element. Potentially, this could be greatly wasteful for larger strings with many erase operations. Perhaps building a new string rather than modifying the existing string could allow for a more efficient solution without really sacrificing on the readability afforded by a single erase function.
a possible solution is to skip the characters '-' and '_' with "continue" and store it in another string
it looks same with my own XD
It will be great, if you explain your ideas.
No
I'd better use "i++;" before the line "text[i] = toupper(text[i])" instead of line "text.erase(i, 1);".
This is an O(n^2) solution.
The text.erase(i,1) cause the whole remaining string to be moved down one space before continuing.
i.e. There is a hidden loop there inside the loop.
Would have been much better to use the Erase/Remove idiom.
Isn't it very time consuming if you are shitfing all the elemnts (by erase() ) every time '-' or '_' is found?
Loading more items...