sir/mam i think my algorithm work fine but passed only 3 test case what may be the reason behind my code.
@Korou I have fixed your code. I have replaced char[] with string. Now the code works fine.