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.
what would you say about my solution? I joined late and I'm trying to get some appreciation :P
The main disadvantage of a std::map is that--if not a constexpr--has program startup initialization overhead whereas case statements are purely pay-for-play. It also has a slightly larger memory footprint than a case statement which, as noted, typically are encoded into efficient lookup tables. But, as always, profile the code if it's a bottleneck.
Some interesting reading on the subject including whether or not it matters in the long run:
https://stackoverflow.com/questions/931890/what-is-more-efficient-a-switch-case-or-an-stdmap
A bench mark of a solution using a switch statement vs. a map:
https://quick-bench.com/q/0nlyy0psC7kAySMt-BiKIPVaMYE
Generally (but not always) if all the values are known before-hand a switch statement will be quicker and a map is more useful if you want to add to the map later in your program.
I am not 100% on this stuff as I am still early in my studies but I would think switch would still be quicker as it is O(1) time complexity and std::string.find() is O(n * m).
Maybe someone more knowledgeable than me can chime in.
Map seems useful, just learnt about it. Is it that slow? Also do you have idea wheter std :: string.find() is quicker than a switch statement?
Whilst this solution does pass the test it has changed the parameter from a const. This would be considered bad practice as it edits the original value.
This comment is hidden because it contains spoiler information about the solution