Not getting desired output..please tell what is wrong in my approach

I am not able to get your approach. Can you please explain what you are trying to do here?
Also, your loops arent even running once. As you’re taking int l=s.length(); so value of l would be 1 only, and looping i from 0 to l-1 which is zero loop.