query on extending capacity of input

my algo:-
let s=lrlr
if no. of char is even level is odd else even;
so n=2^(strlen) is no. of no.s in this lvl;
next analyze string ;
if r occurs search occurs in n/2+1 to n;
or if l occrs search in element 1 to n/2;
ans is coming ;
but how to extend for large strings??

it gives 0 or -ve values for large s;

//