Please help me to debug this python code for LENT MONEY :

https://www.codechef.com/viewsolution/24815620

I have used a tuple to separate the numbers having gained from those having loss

Can I also remove TLE using the same approach of tuple

Please help me to debug this python code for LENT MONEY :

https://www.codechef.com/viewsolution/24815620

I have used a tuple to separate the numbers having gained from those having loss

Can I also remove TLE using the same approach of tuple

We create a new array, where we store the effect we have on a number when we xor it with ‘x’ (b[i]= a[i]-a[i]^x) . Xor any number with ‘x’ 2 times/even number of times and you get the same result …a[i]^x^x…(even number of times)=a[i].

if k is odd, answer is the sum of all positive numbers;

if k is even and there are even number of positive numbers in the array; answer is same as above.

if k is even,and number of positive numbers is odd, then answer is max(positive sum-smallest positive number,positive_sum+smallest negative number ). Hope this helps