Need an optimized solution

question link:
https://online.codingblocks.com/player/10194/content/5368

Hey Nitin, this link is not accessible, can you mention the problem’s exact name and share the link of your code.