Here mentioned the changes in code https://ide.codingblocks.com/s/392898 updated ur code
One such instance where its failing otherwise 4 2 1 2 3 5 6 7 7 8