Another approach or optimization

Is there any optimized solution for this

@shashank.21sep can we see your implementation so that we can suggest

https://ide.codingblocks.com/s/72143

@shashank.21sep hey shashank you don’t need to confuse and not expected to write more no of the line of the code
you can refer to this link for simple code
simple code.