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.
difference between O(n) and O(3n) is only about micro-optimizations. Meaning you cannot have any general rule about that. That's precisely why, when talking about time complexity, you're always reducing O(3n) to O(n).
For example, doing only 1 pass, you'll generally need extra condition checks. That takes time... => That slowes down the O(n) implemetation... => That's microoptimization matter... => That's pointless to make general comparisons between O(n) and O(3n) because behaviors will depend on compiler, implementation, interpreter if any, ..., ..., ..., ...
Big O notation is cool, but n is still way better than 3n.
This solution seems to be missing an empty string check, thus potential undefined behaviour: https://en.cppreference.com/w/cpp/string/basic_string/pop_back
Ah. You're right. I feel blind.
Creating the list is still O(N)
This comment is hidden because it contains spoiler information about the solution
Thank you for the tip!
Since c++11 it's allowed to use simpler initialisation lists for (amongst others) maps, so instead of std::make_pair('A', 'T') you may use just {'A', 'T'}
This comment is hidden because it contains spoiler information about the solution
nice I do not know why i did not think of that .... will get better over time i guess