Please explain. Show what the code is doing and explain what it should have done.
Try testing with a smaller String of binary digits before attempting to solve the long ones.