Binary Prefix Divisible By 5 Problem

Binary Prefix Divisible By 5 Problem — ExecCode Easy DSA Practice

Solve the Binary Prefix Divisible By 5 problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a binary array nums (0-indexed). Your task is to compute the required answer and return an array of booleans answer where answer[i] is true if xi is divisible by 5. 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], then x0 = 1, x1 = 2, and x_2 = 5.

Examples

Input {"nums": [0, 1, 1]}; Output [true, false, false]. Input {"nums": [1, 1, 1]}; Output [false, false, false]. Input {"nums": [0, 1, 1]}; Output [True, False, False]

Constraints

1 <= nums.length <= 10^5 nums[i] is either 0 or 1.

Practice Binary Prefix Divisible By 5 free on ExecCode. Browse DSA problems, topic map, and placement guides.