Pattern triangle

Code is working fine with custom input but on submission, is giving wrong answer.

HI,
Your code has some space related problem . Please check the comments in the given code.