lc-go/solutions/10/q1018/solution.go

16 lines
321 B
Go

// Package q1018 implements a solution for https://leetcode.com/problems/binary-prefix-divisible-by-5/
package q1018
func prefixesDivBy5(nums []int) []bool {
ret := make([]bool, len(nums))
num := 0
for i, n := range nums {
num = num<<1 + n
ret[i] = num%5 == 0
num %= 5
}
return ret
}
var _ = prefixesDivBy5