Failed Test Cases

Hello SIr!

Upon checking with custom input, the output is as desired.
But it’s not passing the test cases.

Can you help me with it?

please share ur code

#include
using namespace std;

int main() {

int n; cin >> n;
int nsp = n-1;
int num = 1;

for(int i = 1; i <= n; i++)
{
	//Spaces
	for(int csp = 0; csp <= nsp; csp++)
		cout << "	";
	
	//Numbers
	for(int cst = 1; cst <= ((2*i)-1); cst++)
	{
		cout << num << "	";

		if(cst < i)
			num++;
		else
			num--;
	}
	cout << endl;
	nsp--;
	num+=2;
}


return 0;

}


see this is ur output. in this u are leaving this extra space in front. that why ur code is not passing test cases. try to figure it out

Done sir! Thank you.

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.

1 Like