Problem:
Solution (wrong answer):
But unable to detect, what’s wrong with this answer, as expected it gives the same output given in above question. Please correct @chi
What other test cases have you tried? Post your test data, and let’s take a look.