Total Complexity | 6 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class BinaryPrefixDivisibleByFive |
||
8 | { |
||
9 | public static function prefixesDivByFive(array $arr): array |
||
10 | { |
||
11 | if (empty($arr)) { |
||
12 | return []; |
||
13 | } |
||
14 | [$ans, $num] = [[], 0]; |
||
15 | foreach ($arr as $val) { |
||
16 | $num = ($num * 2 + $val) % 5; |
||
17 | $ans[] = $num === 0; |
||
18 | } |
||
19 | |||
20 | return $ans; |
||
21 | } |
||
22 | |||
23 | public static function prefixesDivByFive2(array $arr): array |
||
35 | } |
||
36 | } |
||
37 |