Hacker rank valley question on string

Sir my test case is showing segmentation fault

#include
#include
using namespace std;
int main(){
int n;
cin>>n;

string s[n];
int altitude =0;
int valley=0;
cin.get();

for(int i=0;i<n;i++){
getline(cin,s[i]);}
for(int i=0;i<n;i++){
if(s[i]==“U”){
if(valley==0){valley++;}
altitude++;}
else if (s[i]==“D”) {altitude–;}
else{altitude=altitude;}}
cout<<valley<<endl;}

Hey @ahujashantanu2904
Please share your code in coding blocks ide

Hey @ahujashantanu2904
Are u submitting this code on the platform because u only have to complete function on hackerrnk
Please share the code which u are submitting there and also with proper indentation.

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.