PLS HELP ME! ERROR-/bin/run.sh: line 4: 21 Segmentation fault (core dumped) ./exe

#include<bits/stdc++.h>
using namespace std;

int main() {

int n;
cin>>n;
cin.get();

string s[n];

for(int i=0;i<n;i++){
	
	getline(cin,s[i]);
}

sort(s,s+n);

for(int i=0;i<n;i++){
	string sub=s[i];
	int indx=s[i+1].find(sub);
	if(indx<n) swap(s[i],s[i+1]);
}


for(int i=0;i<n;i++){
	cout<<s[i]<<endl;
}

return 0;

}

hi @anshul3558_e8c9aa486c392ca3,
refer this ive commented https://ide.codingblocks.com/s/664987

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.