Created
August 30, 2016 10:37
-
-
Save evilmucedin/932b92c1532a18753f5f674b4434d4d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -O3 Spaces.cpp -o Spaces --std=c++14 -march=native -g; time ./Spaces | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
static string InjectSpaces(const string& s) { | |
string result(2*s.length() - 1, ' '); | |
const auto length = s.length(); | |
for (auto i = 0; i < length; ++i) { | |
result[2*i] = s[i]; | |
} | |
return result; | |
} | |
int main() { | |
string s = "1234567890"; | |
string result; | |
for (size_t i = 0; i < 200000000; ++i) { | |
result = InjectSpaces(s); | |
} | |
cout << result << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍