Hello can anyone tell me what is wrong with my code https://www.codechef.com/viewsolution/26856999

The logic i used is sort r and find each character of s in using binary search and erase those characters. if not found impossible else insert s in r just where s[0]>r[i]. It would be helpful if anyone could point out the flaw. Thank you!