Pattern mountain

#include
using namespace std;
int main() {
int n;
cin>>n;
int i,j;
int m=2*n;
char sp=’ ‘;
for(i=1;i<=n;i++){
for(j=1;j<=m-1;j++){
if(j<=i){
cout<<j<<’ ‘;
}
if(j>=m-i){
cout<<m-j<<’ ‘;
}
else{
cout<<sp<<’ ';
}

    }
    cout<<endl;
}
return 0;

}

output:
1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1

what part of my code is wrong?

@kashikahingorani this problem have three case
follow this discuss

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.