This was my code for the problem ALT_TAB in todays contest.
When I enter the input manually and press enter after inputting 9 and carry on with the rest of the input, the program works completely fine
But on submitting it or when I copy the input and then run it, it is asking for more input i.e. SIGTSTP. Is a special character such as newline or something like that after 9, hindering the solution?
include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
stack s;
for(int i=0; i<n; i++){
string s1;
cin >> s1;
s.push(s1);
}
set ans;
while(!s.empty()){
string a = s.top();
if(ans.count(a))
continue;
else
ans.insert(a);
int l = a.length();
char ch;
for (int i = l-2; i < l; i++) {
ch = a.at(i);
cout << ch;
}
s.pop();
}
return 0;
}