code:https://ide.codingblocks.com/s/249361
@chhavibansal getting tle for same case with u r answer also