Check my code , output is wrong

You can verify your approach from here