Run error in two of the test cases

i am getting run error in test case 0 and 1
here is my code

First of all i think the time complexity of your code is large so rather than inserting inside the string i would recommend you to just append using += and then just reverse the whole string .
And also

while(i!=0 and j!=0)

this is the while loop condition.