Time Limit Exceeded in Mountain Pattern

Can somebody please help me in understanding what the error in the code is and why it is giving Time Limit Exceeded error

2 things

  • you need to increment your row in every loop,otherwise its an infinite loop giving tle
  • then you need to correct the spaces for your code as for input= 2 you are getting output
    1 1
    1 2 2 1

Thank you so much Abha. The code is working fine now after making the edits that you told.

no problem :slight_smile: please mark your doubt as resolved and rate as well