1 test case is not passing code link - https://ide.codingblocks.com/s/194381
I have edited your code… Kindly refer to it…