[Solved] Runtime error in Cyclic Binary String Question [closed]


What means dividable by the largest power of 2?

xyz10000

is dividable by

   10000

So a 1 fby 0s. Otherwise it would not be dividable.

If there is no 1, the result is -1.

For rotatation equivalence, you are looking for the longest sequence of 0s which might be situated at front and tail of the sequence.

Now java’s BitSet can juggle with bit operations, like find the next bit 1 from a given position.

To recap:

  1. Look at the abstract problem, find the logic
  2. Pick the data structure
  3. Code it

Especially step 1 is very illuminating, yielding a very simple problem.
The key phrase being “the longest sequence of zeros.”

I hope I did not spoil the coding.

7

solved Runtime error in Cyclic Binary String Question [closed]