The Full Counting Sort

  • + 0 comments

    In C++, String need contiguous memory to store sequence of character. When you need to expand string by insert or append, If current capacity of string is not enough, it need to allocation memmory with proper capacity, and copy old string to this position before expand this string. So it need many time to do all this action and make time out in this challenges because you append string many times. ostringstream don't need contiguous memory. It store list of string object. In addition, If you know exactly maximum size of string, you can using reserve function to avoid it allocate memory many times.