Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //100/100
- //Memory: 14.89 MB Time : 1.570 s
- #include <iostream>
- #include <string>
- #include <unordered_map>
- using namespace std;
- int main()
- {
- const int dnaLength = 5;
- string input;
- input.reserve(20971203);
- getline(cin, input);
- unordered_map<string, int> counts;
- string currentDNA;
- for (size_t i = 0, currentIndex = 0; i < input.size() / dnaLength; i++, currentIndex += dnaLength)
- {
- currentDNA = input.substr(currentIndex, dnaLength);
- if (++counts[currentDNA] > 1)
- counts.erase(currentDNA);
- }
- cout << counts.begin()->first << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement