Please let me know for the error ,why it is not running?

Hello @shubhankar1996.dob1 there is problem in this line of your code:
ch=(ch[i]!=ch[i+1])?stre(ch,i+1):ch.insert(i,l2);stre(ch,i+1);
when it has found the duplicacy then this condition will not make further call as it will be end due to your condition.
you have to modify this statement of yours.
and also i think you have to modify your logic you can check this cindition separately.
Happy Learning!!