C solution with DFA; general purpose
A general purpose solution written in C with DFA:\n\nc\nbool* prefixesDivBy5(int* A, int ASize, int* returnSize){\n    *returnSize = ASize;\n    bool *res = (bo
A general purpose solution written in C with DFA:\n\n```c\nbool* prefixesDivBy5(int* A, int ASize, int* returnSize){\n    *returnSize = ASize;\n    bool *res = (bool *)malloc(ASize * sizeof(bool));\n\n    int q0 = 0, q1 = 1, q2 = 2, q3 = 3, q4 = 4;\n    int DFA[5][2] = { {q0, q1}, {q2, q3}, {q4, q0}, {q1, q2}, {q3, q4} };\n\n    int status = q0;\n    for (int i = 0; i < ASize; i++) {\n        status = DFA[status][A[i]];\n        res[i] = status == q0;\n    }\n\n    return res;\n}\n\n```\n\n For the DFA, see:\n \n*  https://www.quora.com/How-do-i-check-if-a-binary-number-is-divisible-by-say-n\n \n*  https://stackoverflow.com/questions/21897554/design-dfa-accepting-binary-strings-divisible-by-a-number-n
['C']