Skip to content

Commit 7f5165d

Browse files
refactor 1018
1 parent fa7b64c commit 7f5165d

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/main/java/com/fishercoder/solutions/_1018.java

+3-33
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,11 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
/**
7-
* 1018. Binary Prefix Divisible By 5
8-
*
9-
* Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.)
10-
*
11-
* Return a list of booleans answer, where answer[i] is true if and only if N_i is divisible by 5.
12-
*
13-
* Example 1:
14-
*
15-
* Input: [0,1,1]
16-
* Output: [true,false,false]
17-
* Explanation:
18-
* The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10. Only the first number is divisible by 5, so answer[0] is true.
19-
* Example 2:
20-
*
21-
* Input: [1,1,1]
22-
* Output: [false,false,false]
23-
* Example 3:
24-
*
25-
* Input: [0,1,1,1,1,1]
26-
* Output: [true,false,false,false,true,false]
27-
* Example 4:
28-
*
29-
* Input: [1,1,1,0,1]
30-
* Output: [false,false,false,false,false]
31-
*
32-
*
33-
* Note:
34-
*
35-
* 1 <= A.length <= 30000
36-
* A[i] is 0 or 1
37-
* */
386
public class _1018 {
397
public static class Solution1 {
40-
/**credit: https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/266051/Java-beats-100*/
8+
/**
9+
* credit: https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/266051/Java-beats-100
10+
*/
4111
public List<Boolean> prefixesDivBy5(int[] A) {
4212
List<Boolean> result = new ArrayList<>(A.length);
4313
int remainder = 0;

0 commit comments

Comments
 (0)