I am curious as to where I am going wrong in my code. It seems that there are some submissions that contain the same logic, but somehow my code gets a SIGSEGV error. Can anyone please help me and let me know where I am going wrong? Your help will be much appreciated.
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
string s;
cin>>s;
int count = 0;
for(int i = 0; i < s.size()-3; ++i){
string temp ;
for(int j = i;j < i+4; ++j){
temp.push_back(s[j]);
}
sort(temp.begin(),temp.end());
if(temp == "cefh")++count;
}
count > 0?cout<<"lovely "<<count<<endl:cout<<"normal"<<endl;
}
return 0;
}
Problem: CHEFCHR Problem | CodeChef