package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/binary-prefix-divisible-by-5/
 */
public class Problem1018 {
    public List<Boolean> prefixesDivBy5(int[] A) {
        List<Boolean> answer = new ArrayList<>();
        // TODO
        return answer;
    }

    public static void main(String[] args) {
        Problem1018 prob = new Problem1018();
        System.out.println(prob.prefixesDivBy5(new int[]{0, 1, 1})); // [true,false,false]
        System.out.println(prob.prefixesDivBy5(new int[]{1, 1, 1})); // [false,false,false]
        System.out.println(prob.prefixesDivBy5(new int[]{0, 1, 1, 1, 1, 1})); // [true,false,false,false,true,false]
    }
}

@@ -275,436 +275,227 @@
     
-// TODO%0A        return answer
+int remainder = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1018 prob = new Problem1018();%0A        System.out.println(prob.prefixesDivBy5(new int%5B%5D%7B0, 1, 1%7D)); // %5Btrue,false,false%5D%0A        System.out.println(prob.prefixesDivBy5(new int%5B%5D%7B1, 1, 1%7D)); // %5Bfalse,false,false%5D%0A        System.out.println(prob.prefixesDivBy5(new int%5B%5D%7B0, 1, 1, 1, 1, 1%7D)); // %5Btrue,false,false,false,true,false%5D
+for (int i = 0; i %3C A.length; i++) %7B%0A            remainder = A%5Bi%5D == 0 ? (remainder * 2) %25 5 : (remainder * 2 + 1) %25 5;%0A            answer.add(remainder == 0);%0A        %7D%0A        return answer;
 %0A   

Solve problem 1018