1018. Binary Prefix Divisible By 5 Easy

@problem@discussion
#Array



1/**
2 * [1018] Binary Prefix Divisible By 5
3 *
4 * You are given a binary array nums (0-indexed).
5 * We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit).
6 * 
7 * 	For example, if nums = [1,0,1], then x0 = 1, x1 = 2, and x2 = 5.
8 * 
9 * Return an array of booleans answer where answer[i] is true if xi is divisible by 5.
10 *  
11 * Example 1:
12 * 
13 * Input: nums = [0,1,1]
14 * Output: [true,false,false]
15 * Explanation: The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.
16 * Only the first number is divisible by 5, so answer[0] is true.
17 * 
18 * Example 2:
19 * 
20 * Input: nums = [1,1,1]
21 * Output: [false,false,false]
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= nums.length <= 10^5
27 * 	nums[i] is either 0 or 1.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/binary-prefix-divisible-by-5/
33// discuss: https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn prefixes_div_by5(nums: Vec<i32>) -> Vec<bool> {
39        vec![]
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_1018() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.