Hi all, I’m trying to solve a problem and in my solution I’m having very very long std::strings that need to be gone over character by character a lot of times. For this reason, the solution exceeds the time limit of 1 sec, so I’ve decided to replace my usage of strings with usage of char, hoping, since it’s a “lower-level” data structure than std::string, it would make my solution faster.
My question is, how (quickly) are arrays initialized in the memory?
Would “char Arr1” take as much time as “char Arr2” just for initialization ?
I’m asking because I wonder if it’s okay to let every single array of chars be of a very large size even if it will only contain a few elements, and most of it will be empty, or should I initialize the arrays corresponding to how many elements I need to store in them?
Is there anything else I can replace std::string with for improved speed, other than char? What about array<char, size>?