|
|
back to board#include <iostream> #include <string> using namespace std; void main() { string shifr; cin >> shifr; for (int n = 0;n<shifr.length();n++) { for (int i = 0;i<shifr.length()-1;i++) { if(shifr[i]==shifr[i+1]) { shifr.erase(i,2); } } } cout << shifr << endl; } I have got crash on test 2 First of all you will get TLE for your solution. Just use the Stack data structure and insert each characters one by one from the input string by comparing them with the lastly pushed character. If they match, then pop it off that lastly pushed character. Then printout the stack in reverse. That's all :) |
|
|