Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f5165d

Browse files
refactor 1018
1 parentfa7b64c commit7f5165d

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,11 @@
33
importjava.util.ArrayList;
44
importjava.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
publicclass_1018 {
397
publicstaticclassSolution1 {
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
publicList<Boolean>prefixesDivBy5(int[]A) {
4212
List<Boolean>result =newArrayList<>(A.length);
4313
intremainder =0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp