To find the bug the number of boxes between the box that u opened already and the box that the bug exists should be an odd number .
When ever u move to another box and then bug also moves to other box then the number of boxes between your box and rat box should add up to two or zero. The nature of number of boxes remains same (if odd it remains odd if even remains even)
So now start from 1 and go to 10 definitely there is a crossing point of u and bug. if not occurs then intially u and bug are differ by even number of boxes so when u reaches 10 open the box 10 again then now the number of boxes that u and bug separated by an odd number of boxes so now move to number 1 box backward and there will be a point of crossing .u will find a bug .