Want to optimise my code

this code is submitted and passed but this looks very lengthy. Can ti be optimised or please u can tell me any optimised code
Actually pattern code are very lengthy so what is the write way to solve them so they become optimise and easy

Don’t afraid of lengthy code. If it is your code, then it is best. Logic must be correct. Actually pattern code is really very long. But if you want shortcode then you can refer this but it is hard to understand. https://ide.codingblocks.com/s/220477

1 Like

hi @anujsharmabadboy the length of the code doesn’t matter as much, the time complexity does. Optimization means reducing space and time complexity, the length of your code rarely matters. Pattern codes may seem long but as you come across more problems you will see what I mean. Your algorithm is correct and that’s good enough when you are starting out.

1 Like

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