Failing all base cases and edge cases

I implemented the solution given in the video. Using that solution, 14 test cases were failing. I modified the solution for negative node values. I am still failing 11 test cases. Unable to spot the error.

1 Like

You need to observe that the mistake happens in cases with negative numbers. This is because:

7 % 2 ===> 1
6 % 2 ===> 0
But,
-7 % 2 ===> -1
6 % 2 ===> 0

Please keep this in mind and debug your solution

2 Likes

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.