Adjacency Hatred

Don’t Known why code is not working for hidden test cases

Problem Link : Contest Page | CodeChef
Solution Link :- Solution: 51342097 | CodeChef

This test case will not pass your code.
1
4
5 3 1 6

Number of even values = 1
Number of odd values = 3
Though, the number of even values and number of odd values is different, it is still possible to find a permutation to fit the condition.

1 Like

Your code is wrong. Even when number of odd numbers and even numbers is not equal then too odd sum of differences can be created. Only two cases form when numbers of odd numbers is zero or when number of even numbers is zero else it would always be possible to form odd sum of differences.

1 Like