• + 0 comments

    Even though the code is incorrect, it passes the test cases. The reason is: when A[x] is even, and both A[x+1] = 0 and A[x+2] = 0, the result should be Even. However, the code does not handle this correctly, yet it still passes the tests.

    If A[x] is odd, then the recursive result is Odd.
    If A[x] is even, check whether A[x+1] is 0 recursively:
        If A[x] is even and A[x+1] is 0, then the result is Odd.
        If A[x] is even and A[x+1] is not 0, then the result is Even.