We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Even Odd Query
You are viewing a single comment's thread. Return to all 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.