Ctrl K

Multiple of Five at Every Step

Easy
Binary digits from the list bits are appended one at a time to the right end of a display. After each new digit, the display shows the binary number formed by all digits so far (most significant on the left). Return a list of booleans of the same length whose i-th item is True if the number on the display after digit i is divisible by 5, and False otherwise. The numbers can get very long.
Example 1
bits=[1, 0, 1, 0] → [False, False, True, True]

The board shows 1, 10, 101, 1010 in turn, which are 1, 2, 5, 10. The last two are multiples of 5.

Example 2
bits=[0, 1, 1] → [True, False, False]

The numbers are 0, 1, 3. Zero is a multiple of 5, the others are not.

Constraints
  • 1 ≤ bits.length ≤ 5·10⁵
  • bits[i] is 0 or 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Unpaired Value EasyThe Lost Ticket EasyDoubled Tag, Lost Tag EasyMirror and Negate a Bitmap EasyOrder by Set Bits Easy
loading Python…
Input
bits=[1, 0, 1, 0]
Expected
[False, False, True, True]

Run checks the first 3 tests in your browser. Submit checks all 71 tests on the server, hidden ones included.