Chef and String

my solution link is https://www.codechef.com/viewsolution/19411078
i don’t understand where am i wrong. please help me out.