1018. Binary Prefix Divisible By 5
https://leetcode.com/problems/binary-prefix-divisible-by-5
Description
You are given a binary array nums
(0-indexed).
We define xi
as the number whose binary representation is the subarray nums[0..i]
(from most-significant-bit to least-significant-bit).
For example, if
nums = [1,0,1]
, thenx0 = 1
,x1 = 2
, andx2 = 5
.
Return an array of booleans answer
where answer[i]
is true
if xi
is divisible by 5
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= nums.length <= 105
nums[i]
is0
or1
.
ac
Last updated