It is passing both example input and case shown in image.
@vivek21, I have corrected your code https://ide.codingblocks.com/s/188652