Not passing all the cases


I used the same approach but the code is a bit different. Instead of adding ‘0’ or ‘1’ in end , I preferred to add it in the beginning. My solution was able to pass through only one case. Pls help with my mistake?